@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,356 @@
1
+ <script setup lang="ts">
2
+ import { computed, onMounted, ref, watch } from 'vue'
3
+ import { formatClock, formatCount } from '../../utils/format'
4
+ import { bodyLimit } from '../../utils/logsQuery'
5
+ import {
6
+ axisTicks,
7
+ liveStatus,
8
+ minuteBars,
9
+ peakBar,
10
+ type MinuteBucket,
11
+ } from '../../utils/minuteHistogram'
12
+
13
+ // The shape of the last hour above the request table: requests per minute by
14
+ // status class, for all traffic whatever the table's filters. It follows the
15
+ // page's Direct / Pause state (`usePageLive`): read again on the live feed and
16
+ // every minute in Direct, still while paused, and it says which. A read that fails says so
17
+ // at once, with the time of the data still shown; the next refresh retries.
18
+ defineOptions({ inheritAttrs: false })
19
+
20
+ const props = defineProps<{
21
+ fetchUrl: string
22
+ /** The live feed (`LIVE_REQUESTS_TOPIC`): the graph is read again on it. */
23
+ realtimeTopic?: string
24
+ /** The body size limit of the capture, in bytes (0: bodies not kept). */
25
+ maxBodyBytes?: number
26
+ pageId?: string
27
+ componentId?: string
28
+ }>()
29
+
30
+ interface LivePayload {
31
+ buckets: MinuteBucket[]
32
+ total: number
33
+ clientErrors: number
34
+ serverErrors: number
35
+ refreshedAt: string
36
+ retentionDays: number
37
+ }
38
+
39
+ const { t } = useI18n()
40
+ const { formatLocale: locale, formatNumber } = useRegionalFormat({
41
+ locale: 'format',
42
+ })
43
+ const dateFormat = useDateFormat()
44
+ const { data, error, pending, refresh } = useApiResource<LivePayload>(
45
+ () => props.fetchUrl,
46
+ )
47
+
48
+ // The paused state is the browser's (the DMS remembers it per page), the
49
+ // server renders Direct: the card says it is paused once mounted, so the
50
+ // hydration finds the markup the server sent.
51
+ const live = usePageLive()
52
+ const mounted = ref(false)
53
+ onMounted(() => (mounted.value = true))
54
+ const isLive = computed(() => !mounted.value || live.isLive.value)
55
+ const failures = ref(0)
56
+
57
+ async function poll() {
58
+ await refresh()
59
+ failures.value = error.value ? failures.value + 1 : 0
60
+ }
61
+
62
+ // The current minute moves without traffic too: read again after a quiet
63
+ // minute.
64
+ usePageLiveRefresh(() => void poll(), {
65
+ realtimeTopic: props.realtimeTopic,
66
+ idleRefresh: 60,
67
+ })
68
+
69
+ // A first load that failed counts as a failed poll: the graph says it is
70
+ // reconnecting at once, not after the next poll.
71
+ watch(pending, (loading) => {
72
+ if (!loading && error.value && failures.value === 0) failures.value = 1
73
+ })
74
+
75
+ const status = computed(() => liveStatus(isLive.value, failures.value))
76
+
77
+ const count = (value: number) => formatCount(value, locale.value)
78
+ const MINUTE: Intl.DateTimeFormatOptions = {
79
+ hour: '2-digit',
80
+ minute: '2-digit',
81
+ }
82
+ const minute = (start: number) => dateFormat.value(MINUTE).format(start)
83
+
84
+ const kept = computed(() => {
85
+ if (!data.value) return ''
86
+ const days = data.value.retentionDays
87
+ if (props.maxBodyBytes === undefined) return t('api.live.kept_days', { days })
88
+ const limit = bodyLimit(props.maxBodyBytes)
89
+ if (limit.unit === 'none') return t('api.live.kept_no_bodies', { days })
90
+ return t('api.live.kept', {
91
+ days,
92
+ size: t(`api.live.size_${limit.unit}`, {
93
+ amount: formatNumber(limit.amount),
94
+ }),
95
+ })
96
+ })
97
+
98
+ const lastData = computed(() =>
99
+ data.value
100
+ ? t('api.live.last_data', {
101
+ time: formatClock(data.value.refreshedAt, dateFormat.value),
102
+ })
103
+ : t('api.live.no_data_yet'),
104
+ )
105
+
106
+ const chart = computed(() =>
107
+ minuteBars(data.value?.buckets ?? [], data.value?.refreshedAt),
108
+ )
109
+ const ticks = computed(() => axisTicks(chart.value.bars))
110
+
111
+ // The chart's text alternative: the totals and the busiest minute.
112
+ const summary = computed(() => {
113
+ const payload = data.value
114
+ if (!payload || payload.total === 0) return t('api.live.summary_empty')
115
+ const peak = peakBar(chart.value.bars)
116
+ return t('api.live.summary', {
117
+ total: count(payload.total),
118
+ client: count(payload.clientErrors),
119
+ server: count(payload.serverErrors),
120
+ peak: count(peak?.total ?? 0),
121
+ time: peak ? minute(peak.start) : '',
122
+ })
123
+ })
124
+
125
+ const hovered = ref<number | null>(null)
126
+ const hoveredBar = computed(() =>
127
+ hovered.value === null ? undefined : chart.value.bars[hovered.value],
128
+ )
129
+
130
+ const tooltip = computed(() => {
131
+ const bar = hoveredBar.value
132
+ if (!bar) return ''
133
+ const parts = [minute(bar.start)]
134
+ if (bar.total === 0) parts.push(t('api.live.tooltip_none'))
135
+ else {
136
+ parts.push(t('api.live.total', { count: count(bar.total) }, bar.total))
137
+ if (bar.clientErrors) parts.push(`4xx ${count(bar.clientErrors)}`)
138
+ if (bar.serverErrors) parts.push(`5xx ${count(bar.serverErrors)}`)
139
+ }
140
+ if (bar.current) parts.push(t('api.live.tooltip_current'))
141
+ return parts.join(' · ')
142
+ })
143
+
144
+ // Kept inside the card: anchored left near the start, right near the end.
145
+ const TOOLTIP_EDGE_BARS = 8
146
+ const tooltipStyle = computed(() => {
147
+ const index = hovered.value ?? 0
148
+ const length = chart.value.bars.length || 1
149
+ const left = ((index + 0.5) / length) * 100
150
+ const shift =
151
+ index < TOOLTIP_EDGE_BARS
152
+ ? '0%'
153
+ : index >= length - TOOLTIP_EDGE_BARS
154
+ ? '-100%'
155
+ : '-50%'
156
+ return { left: `${left}%`, transform: `translateX(${shift})` }
157
+ })
158
+
159
+ const tickStyle = (index: number) => {
160
+ const length = chart.value.bars.length || 1
161
+ if (index === 0) return { left: '0' }
162
+ if (index === length - 1) return { right: '0' }
163
+ return {
164
+ left: `${((index + 0.5) / length) * 100}%`,
165
+ transform: 'translateX(-50%)',
166
+ }
167
+ }
168
+
169
+ // A segment's share of its bar, the bar being its segments' sum.
170
+ const share = (part: number, bar: { heights: Record<string, number> }) => {
171
+ const sum =
172
+ bar.heights.success + bar.heights.clientErrors + bar.heights.serverErrors
173
+ return sum === 0 ? '0%' : `${(part / sum) * 100}%`
174
+ }
175
+ </script>
176
+
177
+ <template>
178
+ <DmsCard :padded="false" class="overflow-hidden">
179
+ <template #header>
180
+ <div class="flex w-full flex-wrap items-center gap-x-3 gap-y-1.5">
181
+ <DmsEyebrow :label="t('api.live.title')" />
182
+ <span class="text-dimmed font-mono text-[11px]">{{ kept }}</span>
183
+ <span class="grow" />
184
+ <span
185
+ v-if="data"
186
+ class="text-muted flex flex-wrap items-center gap-x-2 font-mono text-[11px]"
187
+ >
188
+ <span>
189
+ {{ t('api.live.total', { count: count(data.total) }, data.total) }}
190
+ </span>
191
+ <span class="inline-flex items-center gap-1">
192
+ <span class="bg-(--dms-chart-1) size-2 rounded-[2px]" />
193
+ {{ t('api.live.legend_success') }}
194
+ </span>
195
+ <span class="inline-flex items-center gap-1">
196
+ <span class="bg-warning size-2 rounded-[2px]" />
197
+ 4xx {{ count(data.clientErrors) }}
198
+ </span>
199
+ <span class="inline-flex items-center gap-1">
200
+ <span class="bg-error size-2 rounded-[2px]" />
201
+ 5xx {{ count(data.serverErrors) }}
202
+ </span>
203
+ </span>
204
+ <span
205
+ role="status"
206
+ class="text-warning flex items-center gap-1.5 font-mono text-[11px]"
207
+ >
208
+ <template v-if="status === 'reconnecting'">
209
+ <UIcon name="i-ph-cloud-warning" class="size-3.5" />
210
+ {{ t('api.live.reconnecting') }} · {{ lastData }}
211
+ </template>
212
+ </span>
213
+ <UButton
214
+ v-if="status === 'reconnecting'"
215
+ size="xs"
216
+ color="neutral"
217
+ variant="outline"
218
+ icon="i-ph-arrow-clockwise"
219
+ :label="t('api.common.retry')"
220
+ @click="poll()"
221
+ />
222
+ <span
223
+ v-if="status === 'live'"
224
+ class="text-success flex items-center gap-1.5 font-mono text-[11px]"
225
+ >
226
+ <span
227
+ class="bg-success size-1.5 rounded-full motion-safe:animate-pulse"
228
+ />
229
+ {{ t('api.live.following') }}
230
+ </span>
231
+ <span
232
+ v-else-if="status === 'paused'"
233
+ class="text-muted flex items-center gap-1.5 font-mono text-[11px]"
234
+ >
235
+ <UIcon name="i-ph-pause-fill" class="size-3" />
236
+ {{ t('api.live.paused') }} · {{ lastData }}
237
+ </span>
238
+ </div>
239
+ </template>
240
+
241
+ <div class="px-3 pb-2 pt-1">
242
+ <div v-if="pending" class="flex h-[112px] items-end gap-[2px] px-2">
243
+ <USkeleton
244
+ v-for="index in 60"
245
+ :key="index"
246
+ class="flex-1"
247
+ :style="{ height: `${20 + ((index * 37) % 60)}%` }"
248
+ />
249
+ </div>
250
+ <div v-else-if="data">
251
+ <div class="text-dimmed mb-1 font-mono text-[10px]">
252
+ <template v-if="chart.ceiling">
253
+ {{ t('api.live.scale', { count: count(chart.ceiling) }) }}
254
+ <template v-if="chart.clipped">
255
+ · {{ t('api.live.scale_cut') }}
256
+ </template>
257
+ </template>
258
+ </div>
259
+ <div class="relative" @mouseleave="hovered = null">
260
+ <div
261
+ role="img"
262
+ :aria-label="summary"
263
+ class="flex h-[112px] items-stretch gap-[2px] transition-opacity"
264
+ :class="{ 'opacity-50 grayscale': status === 'reconnecting' }"
265
+ >
266
+ <div
267
+ v-for="(bar, index) in chart.bars"
268
+ :key="bar.start"
269
+ class="relative flex flex-1 flex-col justify-end"
270
+ :class="{ 'dms-api-live-current': bar.current }"
271
+ @mouseenter="hovered = index"
272
+ >
273
+ <div
274
+ v-if="bar.total"
275
+ class="relative flex flex-col-reverse gap-px overflow-hidden rounded-t-[2px]"
276
+ :style="{
277
+ height: `${
278
+ bar.heights.success +
279
+ bar.heights.clientErrors +
280
+ bar.heights.serverErrors
281
+ }%`,
282
+ }"
283
+ >
284
+ <span
285
+ v-if="bar.success"
286
+ class="bg-(--dms-chart-1) block shrink-0"
287
+ :style="{ height: share(bar.heights.success, bar) }"
288
+ />
289
+ <span
290
+ v-if="bar.clientErrors"
291
+ class="bg-warning block shrink-0"
292
+ :style="{ height: share(bar.heights.clientErrors, bar) }"
293
+ />
294
+ <span
295
+ v-if="bar.serverErrors"
296
+ class="bg-error block shrink-0"
297
+ :style="{ height: share(bar.heights.serverErrors, bar) }"
298
+ />
299
+ <span
300
+ v-if="bar.current"
301
+ class="dms-api-live-hatch absolute inset-0"
302
+ />
303
+ </div>
304
+ <span
305
+ v-if="bar.clipped"
306
+ class="bg-inverted absolute inset-x-0 top-0 h-[2px]"
307
+ />
308
+ </div>
309
+ </div>
310
+ <div
311
+ v-if="hoveredBar"
312
+ class="bg-inverted text-inverted pointer-events-none absolute top-0 z-10 -translate-y-[calc(100%+4px)] whitespace-nowrap rounded px-2 py-1 font-mono text-[11px] shadow-sm"
313
+ :style="tooltipStyle"
314
+ >
315
+ {{ tooltip }}
316
+ </div>
317
+ </div>
318
+ <div class="text-dimmed relative mt-1 h-3.5 font-mono text-[10px]">
319
+ <span
320
+ v-for="index in ticks"
321
+ :key="index"
322
+ class="absolute top-0"
323
+ :style="tickStyle(index)"
324
+ >
325
+ {{ minute(chart.bars[index].start) }}
326
+ </span>
327
+ </div>
328
+ </div>
329
+ <DmsEmptyState
330
+ v-else
331
+ size="sm"
332
+ variant="error"
333
+ :title="t('api.live.error')"
334
+ :description="t('api.live.error_description')"
335
+ />
336
+ </div>
337
+ </DmsCard>
338
+ </template>
339
+
340
+ <style scoped>
341
+ /* The minute still running: a hatched track, and its bar hatched over. */
342
+ .dms-api-live-current {
343
+ background-image: repeating-linear-gradient(
344
+ 135deg,
345
+ color-mix(in oklab, var(--ui-border-accented) 60%, transparent) 0 1px,
346
+ transparent 1px 5px
347
+ );
348
+ }
349
+ .dms-api-live-hatch {
350
+ background-image: repeating-linear-gradient(
351
+ 135deg,
352
+ color-mix(in oklab, var(--ui-bg) 55%, transparent) 0 2px,
353
+ transparent 2px 5px
354
+ );
355
+ }
356
+ </style>
@@ -0,0 +1,228 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import {
4
+ clearedLogsFilters,
5
+ hasLogsFilters,
6
+ isAllTime,
7
+ logsEmptyCause,
8
+ readLogsFilters,
9
+ windowPreset,
10
+ withLogsFilters,
11
+ type LogsFilters,
12
+ } from '../../utils/logsQuery'
13
+
14
+ // The request table's empty body, which names what empties it: the search,
15
+ // a link's filters, the period and the other filters of the URL (the DMS
16
+ // table does not count those as filters), else nothing captured yet. Each
17
+ // cause comes with its way out. The table hands it `state`, `search`,
18
+ // `refresh` and `clearSearch`, which empties its search and folds its field
19
+ // like its own "Clear search"; its tab is its own.
20
+ defineOptions({ inheritAttrs: false })
21
+
22
+ const props = defineProps<{
23
+ state?: 'firstRun' | 'filtered' | 'error'
24
+ search?: string
25
+ refresh?: () => void
26
+ /** Unset while nothing is searched. */
27
+ clearSearch?: () => void
28
+ }>()
29
+
30
+ const { t } = useI18n()
31
+ const route = useDmsRoute()
32
+ const router = useDmsRouter()
33
+
34
+ const filters = computed(() => readLogsFilters(route.query))
35
+ // The period the selector applies, whatever source it took it from.
36
+ const period = useApiPeriod()
37
+ const cause = computed(() =>
38
+ logsEmptyCause(props.state, props.search, filters.value, period.value),
39
+ )
40
+
41
+ /** "Last hour · POST · Slow only": the URL's filters, besides the links. */
42
+ function describeFilters(current: LogsFilters): string[] {
43
+ const preset = windowPreset(period.value)
44
+ return [
45
+ preset ? t(`api.logs.windows.${preset}`) : undefined,
46
+ current.method,
47
+ current.slow ? t('api.logs.filters.slow') : undefined,
48
+ ].filter((part): part is string => !!part)
49
+ }
50
+
51
+ /**
52
+ * "Path /api/orders/42 · Last hour": what narrows the rows besides the link
53
+ * the title names.
54
+ */
55
+ function describe(current: LogsFilters): string {
56
+ return [
57
+ current.route && current.path
58
+ ? t('api.logs.empty.path', { path: current.path })
59
+ : undefined,
60
+ ...describeFilters(current),
61
+ ]
62
+ .filter(Boolean)
63
+ .join(' · ')
64
+ }
65
+
66
+ function go(query: Record<string, string>) {
67
+ void router.push({ query })
68
+ }
69
+
70
+ function clearFilters() {
71
+ return {
72
+ label: t('dms.table.clear_filters'),
73
+ icon: 'i-ph-x',
74
+ color: 'neutral' as const,
75
+ variant: 'outline' as const,
76
+ onClick: () => go(clearedLogsFilters(route.query)),
77
+ }
78
+ }
79
+
80
+ function clearSearchAction() {
81
+ const clear = props.clearSearch
82
+ if (!clear) return []
83
+ return [
84
+ {
85
+ label: t('dms.table.clear_search'),
86
+ icon: 'i-ph-x',
87
+ color: 'neutral' as const,
88
+ variant: 'outline' as const,
89
+ onClick: () => clear(),
90
+ },
91
+ ]
92
+ }
93
+
94
+ // "All time", while a narrower period may hide the requests.
95
+ function widen() {
96
+ if (isAllTime(period.value)) return []
97
+ return [
98
+ {
99
+ label: t('api.logs.empty.widen'),
100
+ icon: 'i-ph-arrows-out-line-horizontal',
101
+ color: 'neutral' as const,
102
+ variant: 'outline' as const,
103
+ onClick: () => go(withLogsFilters(route.query, { allTime: true })),
104
+ },
105
+ ]
106
+ }
107
+
108
+ const content = computed(() => {
109
+ const current = filters.value
110
+ const narrowed = describe(current)
111
+ const narrowedLine = narrowed
112
+ ? t('api.logs.empty.narrowed', { filters: narrowed })
113
+ : ''
114
+ switch (cause.value) {
115
+ case 'error':
116
+ return {
117
+ variant: 'error' as const,
118
+ icon: 'i-ph-warning-circle',
119
+ title: t('api.logs.empty.error_title'),
120
+ description: t('api.logs.empty.error_description'),
121
+ actions: [
122
+ {
123
+ label: t('dms.table.load_error_retry'),
124
+ icon: 'i-ph-arrow-clockwise',
125
+ color: 'neutral' as const,
126
+ variant: 'outline' as const,
127
+ onClick: () => props.refresh?.(),
128
+ },
129
+ ],
130
+ }
131
+ case 'search':
132
+ return {
133
+ variant: 'no-result' as const,
134
+ icon: 'i-ph-magnifying-glass',
135
+ title: t('api.logs.empty.search_title', { search: props.search }),
136
+ description: [t('api.logs.empty.search_description'), narrowedLine]
137
+ .filter(Boolean)
138
+ .join(' '),
139
+ actions: [
140
+ ...clearSearchAction(),
141
+ ...widen(),
142
+ ...(hasLogsFilters(current) ? [clearFilters()] : []),
143
+ ],
144
+ }
145
+ case 'link':
146
+ return {
147
+ variant: 'no-result' as const,
148
+ icon: 'i-ph-link-simple',
149
+ title: current.route
150
+ ? t('api.logs.empty.route_title', {
151
+ route: current.route,
152
+ })
153
+ : current.path
154
+ ? t('api.logs.empty.route_title', { route: current.path })
155
+ : current.error
156
+ ? t('api.logs.empty.error_filter_title')
157
+ : t('api.logs.empty.incident_title'),
158
+ description: [t('api.logs.empty.link_description'), narrowedLine]
159
+ .filter(Boolean)
160
+ .join(' '),
161
+ actions: [
162
+ {
163
+ label: t('api.logs.empty.remove_link'),
164
+ icon: 'i-ph-x',
165
+ color: 'neutral' as const,
166
+ variant: 'outline' as const,
167
+ onClick: () =>
168
+ go(
169
+ withLogsFilters(route.query, {
170
+ route: null,
171
+ path: null,
172
+ error: null,
173
+ incident: null,
174
+ }),
175
+ ),
176
+ },
177
+ ...(describeFilters(current).length ? [clearFilters()] : []),
178
+ ],
179
+ }
180
+ case 'filters':
181
+ return {
182
+ variant: 'no-result' as const,
183
+ icon: 'i-ph-funnel',
184
+ title: t('api.logs.empty.filtered_title'),
185
+ description: [
186
+ narrowedLine,
187
+ isAllTime(period.value) ? '' : t('api.logs.empty.period_hint'),
188
+ ]
189
+ .filter(Boolean)
190
+ .join(' '),
191
+ // The period alone is the selector's, nothing to clear.
192
+ actions: [
193
+ ...widen(),
194
+ ...(hasLogsFilters(current) ? [clearFilters()] : []),
195
+ ],
196
+ }
197
+ default:
198
+ return {
199
+ variant: 'no-data' as const,
200
+ icon: 'i-ph-broadcast',
201
+ title: t('api.logs.empty.first_run_title'),
202
+ description: t('api.logs.empty.first_run_description'),
203
+ actions: [
204
+ {
205
+ label: t('api.logs.empty.browse_routes'),
206
+ icon: 'i-ph-tree-structure',
207
+ color: 'neutral' as const,
208
+ variant: 'outline' as const,
209
+ to: '/modules/api/routes',
210
+ },
211
+ ],
212
+ }
213
+ }
214
+ })
215
+ </script>
216
+
217
+ <template>
218
+ <DmsEmptyState
219
+ :variant="content.variant"
220
+ :icon="content.icon"
221
+ :title="content.title"
222
+ :description="content.description"
223
+ :actions="content.actions"
224
+ size="lg"
225
+ hatched
226
+ class="z-10 w-full"
227
+ />
228
+ </template>