@antelopejs/dms-api 0.0.1

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 (224) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +61 -0
  3. package/dist/automation/get-api-health.d.ts +10 -0
  4. package/dist/automation/get-api-health.js +53 -0
  5. package/dist/automation/get-api-health.js.map +1 -0
  6. package/dist/automation/index.d.ts +2 -0
  7. package/dist/automation/index.js +19 -0
  8. package/dist/automation/index.js.map +1 -0
  9. package/dist/automation/query-request-logs.d.ts +18 -0
  10. package/dist/automation/query-request-logs.js +50 -0
  11. package/dist/automation/query-request-logs.js.map +1 -0
  12. package/dist/automation/route-unhealthy.d.ts +9 -0
  13. package/dist/automation/route-unhealthy.js +102 -0
  14. package/dist/automation/route-unhealthy.js.map +1 -0
  15. package/dist/automation/scope.d.ts +2 -0
  16. package/dist/automation/scope.js +18 -0
  17. package/dist/automation/scope.js.map +1 -0
  18. package/dist/config.d.ts +12 -0
  19. package/dist/config.js +38 -0
  20. package/dist/config.js.map +1 -0
  21. package/dist/db/index.d.ts +2 -0
  22. package/dist/db/index.js +19 -0
  23. package/dist/db/index.js.map +1 -0
  24. package/dist/db/models/api_settings.model.d.ts +23 -0
  25. package/dist/db/models/api_settings.model.js +13 -0
  26. package/dist/db/models/api_settings.model.js.map +1 -0
  27. package/dist/db/models/index.d.ts +4 -0
  28. package/dist/db/models/index.js +21 -0
  29. package/dist/db/models/index.js.map +1 -0
  30. package/dist/db/models/request_log.model.d.ts +47 -0
  31. package/dist/db/models/request_log.model.js +127 -0
  32. package/dist/db/models/request_log.model.js.map +1 -0
  33. package/dist/db/models/routes.model.d.ts +22 -0
  34. package/dist/db/models/routes.model.js +9 -0
  35. package/dist/db/models/routes.model.js.map +1 -0
  36. package/dist/db/models/routes_statistics.model.d.ts +23 -0
  37. package/dist/db/models/routes_statistics.model.js +13 -0
  38. package/dist/db/models/routes_statistics.model.js.map +1 -0
  39. package/dist/db/tables/api_settings.table.d.ts +10 -0
  40. package/dist/db/tables/api_settings.table.js +47 -0
  41. package/dist/db/tables/api_settings.table.js.map +1 -0
  42. package/dist/db/tables/index.d.ts +4 -0
  43. package/dist/db/tables/index.js +21 -0
  44. package/dist/db/tables/index.js.map +1 -0
  45. package/dist/db/tables/request_log.table.d.ts +29 -0
  46. package/dist/db/tables/request_log.table.js +107 -0
  47. package/dist/db/tables/request_log.table.js.map +1 -0
  48. package/dist/db/tables/routes.table.d.ts +11 -0
  49. package/dist/db/tables/routes.table.js +50 -0
  50. package/dist/db/tables/routes.table.js.map +1 -0
  51. package/dist/db/tables/routes_statistics.table.d.ts +9 -0
  52. package/dist/db/tables/routes_statistics.table.js +38 -0
  53. package/dist/db/tables/routes_statistics.table.js.map +1 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.js +56 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/middlewares/index.d.ts +1 -0
  58. package/dist/middlewares/index.js +18 -0
  59. package/dist/middlewares/index.js.map +1 -0
  60. package/dist/middlewares/request-log-capture.d.ts +1 -0
  61. package/dist/middlewares/request-log-capture.js +6 -0
  62. package/dist/middlewares/request-log-capture.js.map +1 -0
  63. package/dist/pages/all.d.ts +4 -0
  64. package/dist/pages/all.js +21 -0
  65. package/dist/pages/all.js.map +1 -0
  66. package/dist/pages/index.d.ts +4 -0
  67. package/dist/pages/index.js +21 -0
  68. package/dist/pages/index.js.map +1 -0
  69. package/dist/pages/logs/page.d.ts +9 -0
  70. package/dist/pages/logs/page.js +29 -0
  71. package/dist/pages/logs/page.js.map +1 -0
  72. package/dist/pages/module.d.ts +1 -0
  73. package/dist/pages/module.js +12 -0
  74. package/dist/pages/module.js.map +1 -0
  75. package/dist/pages/routes/page.d.ts +9 -0
  76. package/dist/pages/routes/page.js +29 -0
  77. package/dist/pages/routes/page.js.map +1 -0
  78. package/dist/pages/settings/form.d.ts +3 -0
  79. package/dist/pages/settings/form.js +80 -0
  80. package/dist/pages/settings/form.js.map +1 -0
  81. package/dist/pages/settings/page.d.ts +9 -0
  82. package/dist/pages/settings/page.js +26 -0
  83. package/dist/pages/settings/page.js.map +1 -0
  84. package/dist/pages/summary/page.d.ts +9 -0
  85. package/dist/pages/summary/page.js +29 -0
  86. package/dist/pages/summary/page.js.map +1 -0
  87. package/dist/routes/index.d.ts +5 -0
  88. package/dist/routes/index.js +22 -0
  89. package/dist/routes/index.js.map +1 -0
  90. package/dist/routes/logs.d.ts +7 -0
  91. package/dist/routes/logs.js +128 -0
  92. package/dist/routes/logs.js.map +1 -0
  93. package/dist/routes/monitoring.d.ts +17 -0
  94. package/dist/routes/monitoring.js +101 -0
  95. package/dist/routes/monitoring.js.map +1 -0
  96. package/dist/routes/routes.d.ts +37 -0
  97. package/dist/routes/routes.js +153 -0
  98. package/dist/routes/routes.js.map +1 -0
  99. package/dist/routes/settings.d.ts +24 -0
  100. package/dist/routes/settings.js +92 -0
  101. package/dist/routes/settings.js.map +1 -0
  102. package/dist/routes/summary.d.ts +32 -0
  103. package/dist/routes/summary.js +181 -0
  104. package/dist/routes/summary.js.map +1 -0
  105. package/dist/services/index.d.ts +11 -0
  106. package/dist/services/index.js +28 -0
  107. package/dist/services/index.js.map +1 -0
  108. package/dist/services/introspection/auth.d.ts +4 -0
  109. package/dist/services/introspection/auth.js +33 -0
  110. package/dist/services/introspection/auth.js.map +1 -0
  111. package/dist/services/introspection/errors.d.ts +6 -0
  112. package/dist/services/introspection/errors.js +50 -0
  113. package/dist/services/introspection/errors.js.map +1 -0
  114. package/dist/services/introspection/index.d.ts +53 -0
  115. package/dist/services/introspection/index.js +141 -0
  116. package/dist/services/introspection/index.js.map +1 -0
  117. package/dist/services/introspection/probe.d.ts +18 -0
  118. package/dist/services/introspection/probe.js +155 -0
  119. package/dist/services/introspection/probe.js.map +1 -0
  120. package/dist/services/period.d.ts +11 -0
  121. package/dist/services/period.js +68 -0
  122. package/dist/services/period.js.map +1 -0
  123. package/dist/services/request-log/capture.d.ts +10 -0
  124. package/dist/services/request-log/capture.js +189 -0
  125. package/dist/services/request-log/capture.js.map +1 -0
  126. package/dist/services/request-log/index.d.ts +3 -0
  127. package/dist/services/request-log/index.js +12 -0
  128. package/dist/services/request-log/index.js.map +1 -0
  129. package/dist/services/request-log/prune.d.ts +2 -0
  130. package/dist/services/request-log/prune.js +10 -0
  131. package/dist/services/request-log/prune.js.map +1 -0
  132. package/dist/services/request-log/read.d.ts +6 -0
  133. package/dist/services/request-log/read.js +26 -0
  134. package/dist/services/request-log/read.js.map +1 -0
  135. package/dist/services/request-log/redaction.d.ts +4 -0
  136. package/dist/services/request-log/redaction.js +53 -0
  137. package/dist/services/request-log/redaction.js.map +1 -0
  138. package/dist/services/request-log/util.d.ts +13 -0
  139. package/dist/services/request-log/util.js +114 -0
  140. package/dist/services/request-log/util.js.map +1 -0
  141. package/dist/services/routes-sync.d.ts +5 -0
  142. package/dist/services/routes-sync.js +63 -0
  143. package/dist/services/routes-sync.js.map +1 -0
  144. package/dist/services/scope.d.ts +7 -0
  145. package/dist/services/scope.js +40 -0
  146. package/dist/services/scope.js.map +1 -0
  147. package/dist/services/settings.d.ts +20 -0
  148. package/dist/services/settings.js +86 -0
  149. package/dist/services/settings.js.map +1 -0
  150. package/dist/services/statistics-aggregate.d.ts +67 -0
  151. package/dist/services/statistics-aggregate.js +340 -0
  152. package/dist/services/statistics-aggregate.js.map +1 -0
  153. package/dist/services/statistics-prune.d.ts +2 -0
  154. package/dist/services/statistics-prune.js +25 -0
  155. package/dist/services/statistics-prune.js.map +1 -0
  156. package/dist/services/statistics-read.d.ts +4 -0
  157. package/dist/services/statistics-read.js +48 -0
  158. package/dist/services/statistics-read.js.map +1 -0
  159. package/dist/services/statistics-utils.d.ts +14 -0
  160. package/dist/services/statistics-utils.js +65 -0
  161. package/dist/services/statistics-utils.js.map +1 -0
  162. package/dist/services/statistics-write.d.ts +3 -0
  163. package/dist/services/statistics-write.js +84 -0
  164. package/dist/services/statistics-write.js.map +1 -0
  165. package/dist/services/tree.d.ts +10 -0
  166. package/dist/services/tree.js +128 -0
  167. package/dist/services/tree.js.map +1 -0
  168. package/dist/types/charts.d.ts +9 -0
  169. package/dist/types/charts.js +3 -0
  170. package/dist/types/charts.js.map +1 -0
  171. package/dist/types/constants.d.ts +31 -0
  172. package/dist/types/constants.js +49 -0
  173. package/dist/types/constants.js.map +1 -0
  174. package/dist/types/index.d.ts +3 -0
  175. package/dist/types/index.js +20 -0
  176. package/dist/types/index.js.map +1 -0
  177. package/dist/types/statistics.d.ts +17 -0
  178. package/dist/types/statistics.js +3 -0
  179. package/dist/types/statistics.js.map +1 -0
  180. package/frontend-vue/.editorconfig +12 -0
  181. package/frontend-vue/.prettierrc +12 -0
  182. package/frontend-vue/.vscode/settings.json +26 -0
  183. package/frontend-vue/app/components/ConfigurationView.vue +187 -0
  184. package/frontend-vue/app/components/DocumentationView.vue +224 -0
  185. package/frontend-vue/app/components/LogDetailDrawer.vue +178 -0
  186. package/frontend-vue/app/components/LogsView.vue +347 -0
  187. package/frontend-vue/app/components/RouteDetailTabs.vue +179 -0
  188. package/frontend-vue/app/components/RouteTree.vue +196 -0
  189. package/frontend-vue/app/components/RoutesView.vue +82 -0
  190. package/frontend-vue/app/components/StatsView.vue +268 -0
  191. package/frontend-vue/app/components/SummaryView.vue +657 -0
  192. package/frontend-vue/app/components/TesterPanel.vue +499 -0
  193. package/frontend-vue/app/components/internal/ApiMethodBadge.vue +33 -0
  194. package/frontend-vue/app/components/internal/ApiStatusBadge.vue +28 -0
  195. package/frontend-vue/app/components/internal/PeriodSelect.vue +58 -0
  196. package/frontend-vue/app/components/internal/RouteTreeNode.vue +168 -0
  197. package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +162 -0
  198. package/frontend-vue/app/components/internal/StatusDonut.vue +84 -0
  199. package/frontend-vue/app/components/internal/UnitAreaChart.vue +73 -0
  200. package/frontend-vue/app/composables/useApiIntrospection.ts +344 -0
  201. package/frontend-vue/app/composables/useLogDetailDrawer.ts +50 -0
  202. package/frontend-vue/app/composables/useSelectedPeriod.ts +107 -0
  203. package/frontend-vue/app/composables/useStatsPeriods.ts +139 -0
  204. package/frontend-vue/app/custom-layouts/.gitkeep +0 -0
  205. package/frontend-vue/app/custom-pages/.gitkeep +0 -0
  206. package/frontend-vue/app/utils/httpMethod.ts +49 -0
  207. package/frontend-vue/app/utils/statusClass.ts +49 -0
  208. package/frontend-vue/app/utils/testerRequest.ts +50 -0
  209. package/frontend-vue/dms.frontend.ts +25 -0
  210. package/frontend-vue/eslint.config.mjs +16 -0
  211. package/frontend-vue/i18n/locales/en-GB.json +240 -0
  212. package/frontend-vue/i18n/locales/fr-FR.json +240 -0
  213. package/frontend-vue/package.json +35 -0
  214. package/frontend-vue/pnpm-lock.yaml +5796 -0
  215. package/frontend-vue/pnpm-workspace.yaml +2 -0
  216. package/frontend-vue/public/.gitkeep +0 -0
  217. package/frontend-vue/server/.gitkeep +0 -0
  218. package/frontend-vue/tests/periods.test.ts +145 -0
  219. package/frontend-vue/tests/persistence.test.ts +45 -0
  220. package/frontend-vue/tests/registration.test.ts +28 -0
  221. package/frontend-vue/tests/testerRequest.test.ts +95 -0
  222. package/frontend-vue/tsconfig.json +13 -0
  223. package/frontend-vue/vitest.config.ts +8 -0
  224. package/package.json +67 -0
@@ -0,0 +1,347 @@
1
+ <script setup lang="ts">
2
+ import { computed, onUnmounted, reactive, ref, watch } from 'vue'
3
+ import type {
4
+ LogFilters,
5
+ RequestLogSummary,
6
+ } from '../composables/useApiIntrospection'
7
+ import {
8
+ ANY_FILTER,
9
+ httpMethodColor,
10
+ httpMethodFilterItems,
11
+ } from '../utils/httpMethod'
12
+ import PeriodSelect from './internal/PeriodSelect.vue'
13
+
14
+ const { getLogs } = useApiIntrospection()
15
+ const { loadingDetailId, openLogDetail } = useLogDetailDrawer()
16
+
17
+ const PAGE_SIZE = 50
18
+ const POLL_INTERVAL_MS = 5_000
19
+ // Live mode keeps only the newest N rows in memory so long sessions don't grow
20
+ // unbounded.
21
+ const LIVE_LOG_CAP = 500
22
+
23
+ const route = useDmsRoute()
24
+
25
+ // Deep link from the overview cards: /logs?search=<uri>&period=<value> lands
26
+ // pre-filtered on the route URI and the window the user was looking at.
27
+ function queryString(key: string): string | undefined {
28
+ const value = route.query[key]
29
+ return typeof value === 'string' && value ? value : undefined
30
+ }
31
+
32
+ const deepLinkPeriod = queryString('period')
33
+
34
+ // The window is owned by <PeriodSelect> (shared with the Overview and Routes
35
+ // pages) and stays null until it resolves one, so nothing fetches before the
36
+ // log retention is known. The other three filters start unfiltered.
37
+ const period = ref<string | null>(null)
38
+
39
+ const filters = reactive<{
40
+ method: string
41
+ status: string
42
+ search: string
43
+ }>({
44
+ method: ANY_FILTER,
45
+ status: ANY_FILTER,
46
+ search: queryString('search') ?? '',
47
+ })
48
+
49
+ // buildFilters() below strips the ANY_FILTER sentinel so the backend sees no
50
+ // filter for that field.
51
+ const ANY = ANY_FILTER
52
+
53
+ const { t } = useI18n()
54
+
55
+ const methodOptions = computed(() =>
56
+ httpMethodFilterItems(t('page.api.filters.all_methods')),
57
+ )
58
+
59
+ // "slow" piggybacks on the status select: it maps onto the backend's
60
+ // tab=slow filter (requests above the slowness threshold), which lost its
61
+ // UI entry point when the tab bar was removed.
62
+ const SLOW = 'slow'
63
+
64
+ const statusOptions = computed(() => [
65
+ { value: ANY, label: t('page.api.filters.all_statuses') },
66
+ { value: 'success', label: t('page.api.filters.status_success') },
67
+ { value: 'client-error', label: t('page.api.filters.status_client') },
68
+ { value: 'server-error', label: t('page.api.filters.status_server') },
69
+ { value: SLOW, label: t('page.api.filters.slow_only') },
70
+ ])
71
+
72
+ const rows = ref<RequestLogSummary[]>([])
73
+ const nextCursor = ref<string | null>(null)
74
+ // Starts true: the list is waiting on <PeriodSelect> to name a window, and
75
+ // rendering "no logs match the current filters" during that reads as a broken
76
+ // page rather than a loading one.
77
+ const loading = ref(true)
78
+ const loadingMore = ref(false)
79
+ const error = ref<string | null>(null)
80
+ const live = ref(false)
81
+ let pollHandle: ReturnType<typeof setInterval> | undefined
82
+
83
+ function buildFilters(extra: Partial<LogFilters> = {}): LogFilters {
84
+ const f: LogFilters = { limit: PAGE_SIZE, ...extra }
85
+ if (period.value) f.period = period.value
86
+ if (filters.method && filters.method !== ANY) f.method = filters.method
87
+ if (filters.status === SLOW) f.tab = 'slow'
88
+ else if (filters.status && filters.status !== ANY) f.status = filters.status
89
+ if (filters.search) f.search = filters.search
90
+ return f
91
+ }
92
+
93
+ // Every first-page fetch takes a ticket. A slower response from an earlier
94
+ // filter would otherwise land last and pair its rows with the newer request's
95
+ // cursor, so Load more would append entries from a different query.
96
+ let requestGeneration = 0
97
+
98
+ async function loadFirst() {
99
+ if (!period.value) return
100
+ const generation = ++requestGeneration
101
+ loading.value = true
102
+ error.value = null
103
+ try {
104
+ const page = await getLogs(buildFilters())
105
+ if (generation !== requestGeneration) return
106
+ rows.value = page.results
107
+ nextCursor.value = page.nextCursor
108
+ } catch (e) {
109
+ if (generation !== requestGeneration) return
110
+ error.value = e instanceof Error ? e.message : String(e)
111
+ } finally {
112
+ if (generation === requestGeneration) loading.value = false
113
+ }
114
+ }
115
+
116
+ async function loadMore() {
117
+ if (!nextCursor.value || loadingMore.value) return
118
+ loadingMore.value = true
119
+ try {
120
+ const page = await getLogs(buildFilters({ cursor: nextCursor.value }))
121
+ rows.value = rows.value.concat(page.results)
122
+ nextCursor.value = page.nextCursor
123
+ } catch (e) {
124
+ error.value = e instanceof Error ? e.message : String(e)
125
+ } finally {
126
+ loadingMore.value = false
127
+ }
128
+ }
129
+
130
+ async function pollLatest() {
131
+ try {
132
+ const page = await getLogs(buildFilters())
133
+ if (page.results.length === 0) return
134
+ const existing = new Set(rows.value.map((r) => r._id))
135
+ const fresh = page.results.filter((r) => !existing.has(r._id))
136
+ if (fresh.length > 0) {
137
+ rows.value = fresh.concat(rows.value).slice(0, LIVE_LOG_CAP)
138
+ }
139
+ } catch {
140
+ /* polling errors are silent */
141
+ }
142
+ }
143
+
144
+ function stopPolling() {
145
+ if (pollHandle) {
146
+ clearInterval(pollHandle)
147
+ pollHandle = undefined
148
+ }
149
+ }
150
+
151
+ function toggleLive() {
152
+ live.value = !live.value
153
+ if (live.value) {
154
+ pollHandle = setInterval(pollLatest, POLL_INTERVAL_MS)
155
+ } else {
156
+ stopPolling()
157
+ }
158
+ }
159
+
160
+ let searchDebounce: ReturnType<typeof setTimeout> | undefined
161
+ function onSearchInput() {
162
+ if (searchDebounce) clearTimeout(searchDebounce)
163
+ searchDebounce = setTimeout(() => void loadFirst(), 250)
164
+ }
165
+
166
+ // The window and the two selects all re-run the query. Immediate, so the first
167
+ // fetch is the one that follows <PeriodSelect> resolving its window — nothing
168
+ // fires while it is still null.
169
+ watch(
170
+ () => [period.value, filters.method, filters.status],
171
+ () => void loadFirst(),
172
+ { immediate: true },
173
+ )
174
+
175
+ onUnmounted(stopPolling)
176
+
177
+ // Level labels mirror the module's status terminology ("4xx client" /
178
+ // "5xx server" filters, Client/Server breakdown) — a 4xx is a client error,
179
+ // not a warning.
180
+ function statusLevel(s: number): { label: string; color: string } {
181
+ if (s >= 500) return { label: 'SERVER', color: 'text-error' }
182
+ if (s >= 400) return { label: 'CLIENT', color: 'text-warning' }
183
+ if (s >= 300) return { label: 'INFO', color: 'text-info' }
184
+ return { label: 'INFO', color: 'text-success' }
185
+ }
186
+
187
+ function fmtTimestamp(ts: string): string {
188
+ const d = new Date(ts)
189
+ return `${d.toLocaleTimeString()}.${String(d.getMilliseconds()).padStart(3, '0')}`
190
+ }
191
+
192
+ function fmtRequestId(id: string): string {
193
+ return `req_${id.slice(0, 8)}`
194
+ }
195
+
196
+ const counts = computed(() => {
197
+ let info = 0
198
+ let client = 0
199
+ let server = 0
200
+ for (const r of rows.value) {
201
+ if (r.statusCode >= 500) server++
202
+ else if (r.statusCode >= 400) client++
203
+ else info++
204
+ }
205
+ return { info, client, server }
206
+ })
207
+ </script>
208
+
209
+ <template>
210
+ <div class="flex w-full flex-col gap-5 p-6">
211
+ <header class="flex flex-wrap items-center gap-4">
212
+ <div
213
+ class="grid size-11 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary"
214
+ >
215
+ <UIcon name="i-ph-list-magnifying-glass" class="size-[22px]" />
216
+ </div>
217
+ <div class="min-w-0 flex-1">
218
+ <h1 class="text-2xl font-semibold tracking-tight text-highlighted">
219
+ {{ $t('page.api.logs.title') }}
220
+ </h1>
221
+ <p class="text-sm text-muted">
222
+ {{ $t('page.api.logs.description') }}
223
+ </p>
224
+ </div>
225
+ <div class="flex items-center gap-2">
226
+ <UButton
227
+ :icon="live ? 'i-ph-pause' : 'i-ph-play'"
228
+ :color="live ? 'warning' : 'neutral'"
229
+ variant="ghost"
230
+ size="sm"
231
+ @click="toggleLive"
232
+ >
233
+ {{ live ? $t('page.api.logs.pause') : $t('page.api.logs.live') }}
234
+ </UButton>
235
+ <UButton
236
+ icon="i-ph-arrow-clockwise"
237
+ variant="ghost"
238
+ size="sm"
239
+ :loading="loading"
240
+ @click="loadFirst"
241
+ >
242
+ {{ $t('page.api.logs.refresh') }}
243
+ </UButton>
244
+ </div>
245
+ </header>
246
+
247
+ <DmsCard :padded="false" class="flex flex-col overflow-hidden">
248
+ <!-- Filter toolbar -->
249
+ <div
250
+ class="flex flex-wrap items-center gap-2 border-b border-default px-4 py-3"
251
+ >
252
+ <UInput
253
+ v-model="filters.search"
254
+ size="sm"
255
+ icon="i-ph-magnifying-glass"
256
+ :placeholder="$t('page.api.logs.search_placeholder')"
257
+ class="grow"
258
+ @update:model-value="onSearchInput"
259
+ />
260
+ <PeriodSelect v-model="period" kind="logs" :deep-link="deepLinkPeriod" />
261
+ <USelect v-model="filters.method" :items="methodOptions" size="sm" />
262
+ <USelect v-model="filters.status" :items="statusOptions" size="sm" />
263
+ </div>
264
+
265
+ <div
266
+ v-if="error"
267
+ class="m-4 rounded-lg border border-error bg-error/10 p-3 text-sm text-error"
268
+ >
269
+ {{ error }}
270
+ </div>
271
+
272
+ <!-- Console-style log list. The row list scrolls internally so the
273
+ toolbar and footer stay pinned. -->
274
+ <div
275
+ class="flex max-h-[calc(100vh-24rem)] min-h-[360px] flex-col overflow-hidden font-mono text-xs"
276
+ >
277
+ <div v-if="rows.length === 0 && !loading" class="p-8 text-center text-muted">
278
+ {{ $t('page.api.logs.empty') }}
279
+ </div>
280
+
281
+ <div v-else class="flex-1 overflow-y-auto">
282
+ <div
283
+ v-for="row in rows"
284
+ :key="row._id"
285
+ class="grid cursor-pointer grid-cols-[148px_56px_64px_1fr_56px_64px_104px] items-center gap-2 border-b border-default/40 px-4 py-1.5 hover:bg-elevated/50"
286
+ :class="{
287
+ 'bg-error/5': row.statusCode >= 500,
288
+ 'bg-warning/5': row.statusCode >= 400 && row.statusCode < 500,
289
+ }"
290
+ @click="openLogDetail(row)"
291
+ >
292
+ <span class="text-dimmed">[{{ fmtTimestamp(row.timestamp) }}]</span>
293
+ <span class="font-semibold" :class="statusLevel(row.statusCode).color">
294
+ {{ statusLevel(row.statusCode).label }}
295
+ </span>
296
+ <span class="font-semibold" :class="`text-${httpMethodColor(row.method)}`">
297
+ {{ row.method.toUpperCase() }}
298
+ </span>
299
+ <span class="truncate text-toned">{{ row.uri }}</span>
300
+ <span class="text-right" :class="statusLevel(row.statusCode).color">
301
+ {{ row.statusCode }}
302
+ </span>
303
+ <span class="text-right text-dimmed">
304
+ {{ Math.round(row.responseTimeMs) }}ms
305
+ </span>
306
+ <span class="truncate text-right text-dimmed">
307
+ {{ fmtRequestId(row._id) }}
308
+ <UIcon
309
+ v-if="loadingDetailId === row._id"
310
+ name="i-ph-spinner"
311
+ class="ml-1 animate-spin"
312
+ />
313
+ </span>
314
+ </div>
315
+
316
+ <div v-if="nextCursor" class="p-2 text-center">
317
+ <UButton size="xs" variant="ghost" :loading="loadingMore" @click="loadMore">
318
+ {{ $t('page.api.logs.load_more') }}
319
+ </UButton>
320
+ </div>
321
+ </div>
322
+
323
+ <div v-if="loading && rows.length === 0" class="space-y-1 p-4">
324
+ <USkeleton v-for="i in 8" :key="i" class="h-5 w-full" />
325
+ </div>
326
+ </div>
327
+
328
+ <!-- Status bar (foot) -->
329
+ <div
330
+ class="flex items-center justify-between border-t border-default px-4 py-2.5 text-xs text-dimmed"
331
+ >
332
+ <div class="flex items-center gap-3">
333
+ <span v-if="live" class="flex items-center gap-1.5 text-success">
334
+ <span class="inline-block size-2 animate-pulse rounded-full bg-success" />
335
+ {{ $t('page.api.logs.live_status') }}
336
+ </span>
337
+ <span>{{ rows.length }} {{ $t('page.api.logs.entries') }}</span>
338
+ </div>
339
+ <div class="flex items-center gap-3 font-mono">
340
+ <span>INFO: <b class="text-toned">{{ counts.info }}</b></span>
341
+ <span class="text-warning">CLIENT: <b>{{ counts.client }}</b></span>
342
+ <span class="text-error">SERVER: <b>{{ counts.server }}</b></span>
343
+ </div>
344
+ </div>
345
+ </DmsCard>
346
+ </div>
347
+ </template>
@@ -0,0 +1,179 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch } from 'vue'
3
+ import type {
4
+ RouteDocPayload,
5
+ RouteInspection,
6
+ RouteStatsPayload,
7
+ } from '../composables/useApiIntrospection'
8
+ import ConfigurationView from './ConfigurationView.vue'
9
+ import DocumentationView from './DocumentationView.vue'
10
+ import ApiMethodBadge from './internal/ApiMethodBadge.vue'
11
+ import StatsView from './StatsView.vue'
12
+ import TesterPanel from './TesterPanel.vue'
13
+
14
+ const props = defineProps<{
15
+ routeId: string
16
+ /** Stats window ('Nd'), picked in the tree panel. */
17
+ period?: string
18
+ }>()
19
+
20
+ const { getRouteDoc, getRouteConfig, getRouteStats } = useApiIntrospection()
21
+
22
+ const doc = ref<RouteDocPayload | null>(null)
23
+ const config = ref<RouteInspection | null>(null)
24
+ const stats = ref<RouteStatsPayload | null>(null)
25
+ const docLoading = ref(false)
26
+ const configLoading = ref(false)
27
+ const statsLoading = ref(false)
28
+ const docError = ref<string | null>(null)
29
+ const configError = ref<string | null>(null)
30
+ const statsError = ref<string | null>(null)
31
+
32
+ // Statistics first + active by default, mirroring the DMS mockup where the
33
+ // stats tab is what you land on after picking a route.
34
+ const active = ref<'statistics' | 'documentation' | 'tester' | 'configuration'>(
35
+ 'statistics',
36
+ )
37
+
38
+ const TABS = [
39
+ { value: 'statistics', label: 'page.api.routes.tabs.statistics', icon: 'i-ph-chart-bar' },
40
+ { value: 'documentation', label: 'page.api.routes.tabs.documentation', icon: 'i-ph-book-open' },
41
+ { value: 'tester', label: 'page.api.routes.tabs.tester', icon: 'i-ph-play' },
42
+ { value: 'configuration', label: 'page.api.routes.tabs.configuration', icon: 'i-ph-sliders' },
43
+ ] as const
44
+
45
+ // Pathbar method + location: whichever of doc/config has resolved.
46
+ const pathMethod = computed(
47
+ () => doc.value?.method ?? config.value?.method ?? '',
48
+ )
49
+ const pathLocation = computed(
50
+ () => doc.value?.location ?? config.value?.location ?? '',
51
+ )
52
+
53
+ async function load<T>(
54
+ loader: () => Promise<T>,
55
+ store: { value: T | null },
56
+ loading: { value: boolean },
57
+ error: { value: string | null },
58
+ ) {
59
+ loading.value = true
60
+ error.value = null
61
+ try {
62
+ store.value = await loader()
63
+ } catch (e) {
64
+ error.value = e instanceof Error ? e.message : String(e)
65
+ } finally {
66
+ loading.value = false
67
+ }
68
+ }
69
+
70
+ watch(
71
+ () => props.routeId,
72
+ (id) => {
73
+ doc.value = null
74
+ config.value = null
75
+ stats.value = null
76
+ active.value = 'statistics'
77
+ void load(() => getRouteDoc(id), doc, docLoading, docError)
78
+ void load(() => getRouteConfig(id), config, configLoading, configError)
79
+ void load(() => getRouteStats(id, props.period), stats, statsLoading, statsError)
80
+ },
81
+ { immediate: true },
82
+ )
83
+
84
+ // Period only affects the Statistics tab — doc/config are window-agnostic.
85
+ watch(
86
+ () => props.period,
87
+ () => {
88
+ stats.value = null
89
+ void load(
90
+ () => getRouteStats(props.routeId, props.period),
91
+ stats,
92
+ statsLoading,
93
+ statsError,
94
+ )
95
+ },
96
+ )
97
+ </script>
98
+
99
+ <template>
100
+ <div class="flex h-full flex-col">
101
+ <!-- route pathbar -->
102
+ <div
103
+ class="flex items-center gap-3 border-b border-default px-5 py-4 sm:px-6"
104
+ >
105
+ <ApiMethodBadge v-if="pathMethod" :method="pathMethod" size="md" />
106
+ <USkeleton v-else class="h-6 w-14" />
107
+ <code class="min-w-0 flex-1 truncate font-mono text-sm text-highlighted">
108
+ {{ pathLocation || '—' }}
109
+ </code>
110
+ <DmsCopyButton v-if="pathLocation" :value="pathLocation" />
111
+ </div>
112
+
113
+ <!-- tab bar -->
114
+ <div class="flex items-center gap-1 border-b border-default px-3 sm:px-4">
115
+ <button
116
+ v-for="t in TABS"
117
+ :key="t.value"
118
+ type="button"
119
+ class="-mb-px flex items-center gap-2 border-b-2 px-3 py-2.5 text-sm font-medium transition-colors"
120
+ :class="
121
+ active === t.value
122
+ ? 'border-primary text-primary'
123
+ : 'border-transparent text-muted hover:text-highlighted'
124
+ "
125
+ @click="active = t.value"
126
+ >
127
+ <UIcon :name="t.icon" class="size-4" />
128
+ <span>{{ $t(t.label) }}</span>
129
+ </button>
130
+ </div>
131
+
132
+ <!-- panels -->
133
+ <div class="flex-1 p-5 sm:p-6">
134
+ <!-- Statistics -->
135
+ <template v-if="active === 'statistics'">
136
+ <div v-if="statsError" class="text-sm text-error">{{ statsError }}</div>
137
+ <div v-else-if="statsLoading || !stats" class="flex flex-col gap-4">
138
+ <USkeleton class="h-20 w-full" />
139
+ <USkeleton class="h-56 w-full" />
140
+ </div>
141
+ <StatsView v-else :stats="stats" />
142
+ </template>
143
+
144
+ <!-- Documentation -->
145
+ <template v-else-if="active === 'documentation'">
146
+ <div v-if="docError" class="text-sm text-error">{{ docError }}</div>
147
+ <div v-else-if="docLoading || !doc" class="flex flex-col gap-3">
148
+ <USkeleton class="h-8 w-1/2" />
149
+ <USkeleton class="h-32 w-full" />
150
+ </div>
151
+ <DocumentationView v-else :doc="doc" />
152
+ </template>
153
+
154
+ <!-- Tester -->
155
+ <template v-else-if="active === 'tester'">
156
+ <div v-if="configError" class="text-sm text-error">{{ configError }}</div>
157
+ <div v-else-if="configLoading || !config">
158
+ <USkeleton class="h-8 w-1/3" />
159
+ </div>
160
+ <TesterPanel v-else :route="config" />
161
+ </template>
162
+
163
+ <!-- Configuration -->
164
+ <template v-else>
165
+ <div v-if="configError" class="text-sm text-error">{{ configError }}</div>
166
+ <div v-else-if="configLoading || !config" class="flex flex-col gap-3">
167
+ <USkeleton class="h-8 w-1/3" />
168
+ <USkeleton class="h-24 w-full" />
169
+ </div>
170
+ <ConfigurationView
171
+ v-else
172
+ :parameters="config.parameters"
173
+ :properties="config.properties"
174
+ :middleware="config.applicableMiddleware"
175
+ />
176
+ </template>
177
+ </div>
178
+ </div>
179
+ </template>