@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.
- package/LICENSE +190 -0
- package/README.md +61 -0
- package/dist/automation/get-api-health.d.ts +10 -0
- package/dist/automation/get-api-health.js +53 -0
- package/dist/automation/get-api-health.js.map +1 -0
- package/dist/automation/index.d.ts +2 -0
- package/dist/automation/index.js +19 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/query-request-logs.d.ts +18 -0
- package/dist/automation/query-request-logs.js +50 -0
- package/dist/automation/query-request-logs.js.map +1 -0
- package/dist/automation/route-unhealthy.d.ts +9 -0
- package/dist/automation/route-unhealthy.js +102 -0
- package/dist/automation/route-unhealthy.js.map +1 -0
- package/dist/automation/scope.d.ts +2 -0
- package/dist/automation/scope.js +18 -0
- package/dist/automation/scope.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +19 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/models/api_settings.model.d.ts +23 -0
- package/dist/db/models/api_settings.model.js +13 -0
- package/dist/db/models/api_settings.model.js.map +1 -0
- package/dist/db/models/index.d.ts +4 -0
- package/dist/db/models/index.js +21 -0
- package/dist/db/models/index.js.map +1 -0
- package/dist/db/models/request_log.model.d.ts +47 -0
- package/dist/db/models/request_log.model.js +127 -0
- package/dist/db/models/request_log.model.js.map +1 -0
- package/dist/db/models/routes.model.d.ts +22 -0
- package/dist/db/models/routes.model.js +9 -0
- package/dist/db/models/routes.model.js.map +1 -0
- package/dist/db/models/routes_statistics.model.d.ts +23 -0
- package/dist/db/models/routes_statistics.model.js +13 -0
- package/dist/db/models/routes_statistics.model.js.map +1 -0
- package/dist/db/tables/api_settings.table.d.ts +10 -0
- package/dist/db/tables/api_settings.table.js +47 -0
- package/dist/db/tables/api_settings.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +4 -0
- package/dist/db/tables/index.js +21 -0
- package/dist/db/tables/index.js.map +1 -0
- package/dist/db/tables/request_log.table.d.ts +29 -0
- package/dist/db/tables/request_log.table.js +107 -0
- package/dist/db/tables/request_log.table.js.map +1 -0
- package/dist/db/tables/routes.table.d.ts +11 -0
- package/dist/db/tables/routes.table.js +50 -0
- package/dist/db/tables/routes.table.js.map +1 -0
- package/dist/db/tables/routes_statistics.table.d.ts +9 -0
- package/dist/db/tables/routes_statistics.table.js +38 -0
- package/dist/db/tables/routes_statistics.table.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +18 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/request-log-capture.d.ts +1 -0
- package/dist/middlewares/request-log-capture.js +6 -0
- package/dist/middlewares/request-log-capture.js.map +1 -0
- package/dist/pages/all.d.ts +4 -0
- package/dist/pages/all.js +21 -0
- package/dist/pages/all.js.map +1 -0
- package/dist/pages/index.d.ts +4 -0
- package/dist/pages/index.js +21 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/logs/page.d.ts +9 -0
- package/dist/pages/logs/page.js +29 -0
- package/dist/pages/logs/page.js.map +1 -0
- package/dist/pages/module.d.ts +1 -0
- package/dist/pages/module.js +12 -0
- package/dist/pages/module.js.map +1 -0
- package/dist/pages/routes/page.d.ts +9 -0
- package/dist/pages/routes/page.js +29 -0
- package/dist/pages/routes/page.js.map +1 -0
- package/dist/pages/settings/form.d.ts +3 -0
- package/dist/pages/settings/form.js +80 -0
- package/dist/pages/settings/form.js.map +1 -0
- package/dist/pages/settings/page.d.ts +9 -0
- package/dist/pages/settings/page.js +26 -0
- package/dist/pages/settings/page.js.map +1 -0
- package/dist/pages/summary/page.d.ts +9 -0
- package/dist/pages/summary/page.js +29 -0
- package/dist/pages/summary/page.js.map +1 -0
- package/dist/routes/index.d.ts +5 -0
- package/dist/routes/index.js +22 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/logs.d.ts +7 -0
- package/dist/routes/logs.js +128 -0
- package/dist/routes/logs.js.map +1 -0
- package/dist/routes/monitoring.d.ts +17 -0
- package/dist/routes/monitoring.js +101 -0
- package/dist/routes/monitoring.js.map +1 -0
- package/dist/routes/routes.d.ts +37 -0
- package/dist/routes/routes.js +153 -0
- package/dist/routes/routes.js.map +1 -0
- package/dist/routes/settings.d.ts +24 -0
- package/dist/routes/settings.js +92 -0
- package/dist/routes/settings.js.map +1 -0
- package/dist/routes/summary.d.ts +32 -0
- package/dist/routes/summary.js +181 -0
- package/dist/routes/summary.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +28 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/introspection/auth.d.ts +4 -0
- package/dist/services/introspection/auth.js +33 -0
- package/dist/services/introspection/auth.js.map +1 -0
- package/dist/services/introspection/errors.d.ts +6 -0
- package/dist/services/introspection/errors.js +50 -0
- package/dist/services/introspection/errors.js.map +1 -0
- package/dist/services/introspection/index.d.ts +53 -0
- package/dist/services/introspection/index.js +141 -0
- package/dist/services/introspection/index.js.map +1 -0
- package/dist/services/introspection/probe.d.ts +18 -0
- package/dist/services/introspection/probe.js +155 -0
- package/dist/services/introspection/probe.js.map +1 -0
- package/dist/services/period.d.ts +11 -0
- package/dist/services/period.js +68 -0
- package/dist/services/period.js.map +1 -0
- package/dist/services/request-log/capture.d.ts +10 -0
- package/dist/services/request-log/capture.js +189 -0
- package/dist/services/request-log/capture.js.map +1 -0
- package/dist/services/request-log/index.d.ts +3 -0
- package/dist/services/request-log/index.js +12 -0
- package/dist/services/request-log/index.js.map +1 -0
- package/dist/services/request-log/prune.d.ts +2 -0
- package/dist/services/request-log/prune.js +10 -0
- package/dist/services/request-log/prune.js.map +1 -0
- package/dist/services/request-log/read.d.ts +6 -0
- package/dist/services/request-log/read.js +26 -0
- package/dist/services/request-log/read.js.map +1 -0
- package/dist/services/request-log/redaction.d.ts +4 -0
- package/dist/services/request-log/redaction.js +53 -0
- package/dist/services/request-log/redaction.js.map +1 -0
- package/dist/services/request-log/util.d.ts +13 -0
- package/dist/services/request-log/util.js +114 -0
- package/dist/services/request-log/util.js.map +1 -0
- package/dist/services/routes-sync.d.ts +5 -0
- package/dist/services/routes-sync.js +63 -0
- package/dist/services/routes-sync.js.map +1 -0
- package/dist/services/scope.d.ts +7 -0
- package/dist/services/scope.js +40 -0
- package/dist/services/scope.js.map +1 -0
- package/dist/services/settings.d.ts +20 -0
- package/dist/services/settings.js +86 -0
- package/dist/services/settings.js.map +1 -0
- package/dist/services/statistics-aggregate.d.ts +67 -0
- package/dist/services/statistics-aggregate.js +340 -0
- package/dist/services/statistics-aggregate.js.map +1 -0
- package/dist/services/statistics-prune.d.ts +2 -0
- package/dist/services/statistics-prune.js +25 -0
- package/dist/services/statistics-prune.js.map +1 -0
- package/dist/services/statistics-read.d.ts +4 -0
- package/dist/services/statistics-read.js +48 -0
- package/dist/services/statistics-read.js.map +1 -0
- package/dist/services/statistics-utils.d.ts +14 -0
- package/dist/services/statistics-utils.js +65 -0
- package/dist/services/statistics-utils.js.map +1 -0
- package/dist/services/statistics-write.d.ts +3 -0
- package/dist/services/statistics-write.js +84 -0
- package/dist/services/statistics-write.js.map +1 -0
- package/dist/services/tree.d.ts +10 -0
- package/dist/services/tree.js +128 -0
- package/dist/services/tree.js.map +1 -0
- package/dist/types/charts.d.ts +9 -0
- package/dist/types/charts.js +3 -0
- package/dist/types/charts.js.map +1 -0
- package/dist/types/constants.d.ts +31 -0
- package/dist/types/constants.js +49 -0
- package/dist/types/constants.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/statistics.d.ts +17 -0
- package/dist/types/statistics.js +3 -0
- package/dist/types/statistics.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +12 -0
- package/frontend-vue/.vscode/settings.json +26 -0
- package/frontend-vue/app/components/ConfigurationView.vue +187 -0
- package/frontend-vue/app/components/DocumentationView.vue +224 -0
- package/frontend-vue/app/components/LogDetailDrawer.vue +178 -0
- package/frontend-vue/app/components/LogsView.vue +347 -0
- package/frontend-vue/app/components/RouteDetailTabs.vue +179 -0
- package/frontend-vue/app/components/RouteTree.vue +196 -0
- package/frontend-vue/app/components/RoutesView.vue +82 -0
- package/frontend-vue/app/components/StatsView.vue +268 -0
- package/frontend-vue/app/components/SummaryView.vue +657 -0
- package/frontend-vue/app/components/TesterPanel.vue +499 -0
- package/frontend-vue/app/components/internal/ApiMethodBadge.vue +33 -0
- package/frontend-vue/app/components/internal/ApiStatusBadge.vue +28 -0
- package/frontend-vue/app/components/internal/PeriodSelect.vue +58 -0
- package/frontend-vue/app/components/internal/RouteTreeNode.vue +168 -0
- package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +162 -0
- package/frontend-vue/app/components/internal/StatusDonut.vue +84 -0
- package/frontend-vue/app/components/internal/UnitAreaChart.vue +73 -0
- package/frontend-vue/app/composables/useApiIntrospection.ts +344 -0
- package/frontend-vue/app/composables/useLogDetailDrawer.ts +50 -0
- package/frontend-vue/app/composables/useSelectedPeriod.ts +107 -0
- package/frontend-vue/app/composables/useStatsPeriods.ts +139 -0
- package/frontend-vue/app/custom-layouts/.gitkeep +0 -0
- package/frontend-vue/app/custom-pages/.gitkeep +0 -0
- package/frontend-vue/app/utils/httpMethod.ts +49 -0
- package/frontend-vue/app/utils/statusClass.ts +49 -0
- package/frontend-vue/app/utils/testerRequest.ts +50 -0
- package/frontend-vue/dms.frontend.ts +25 -0
- package/frontend-vue/eslint.config.mjs +16 -0
- package/frontend-vue/i18n/locales/en-GB.json +240 -0
- package/frontend-vue/i18n/locales/fr-FR.json +240 -0
- package/frontend-vue/package.json +35 -0
- package/frontend-vue/pnpm-lock.yaml +5796 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/public/.gitkeep +0 -0
- package/frontend-vue/server/.gitkeep +0 -0
- package/frontend-vue/tests/periods.test.ts +145 -0
- package/frontend-vue/tests/persistence.test.ts +45 -0
- package/frontend-vue/tests/registration.test.ts +28 -0
- package/frontend-vue/tests/testerRequest.test.ts +95 -0
- package/frontend-vue/tsconfig.json +13 -0
- package/frontend-vue/vitest.config.ts +8 -0
- package/package.json +67 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
import type { ApiTreeNode } from '../composables/useApiIntrospection'
|
|
4
|
+
import { ANY_FILTER, httpMethodFilterItems } from '../utils/httpMethod'
|
|
5
|
+
import RouteTreeNode from './internal/RouteTreeNode.vue'
|
|
6
|
+
|
|
7
|
+
// v2 routes tree panel (DMS apiv2-routes): header + filter (search + method
|
|
8
|
+
// select, mirroring the Logs page toolbar) + recursive folder/route tree with
|
|
9
|
+
// per-route health icons. The backend tree is built one folder per path
|
|
10
|
+
// segment; leaves are method nodes whose `value` is the runtime route id used
|
|
11
|
+
// by the per-route endpoints.
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
/**
|
|
14
|
+
* Window ('Nd') the tree health icons are computed over, or null while the
|
|
15
|
+
* page's period selector has yet to resolve one. The tree waits on it rather
|
|
16
|
+
* than fetching a guessed window and reloading a moment later.
|
|
17
|
+
*/
|
|
18
|
+
period: string | null
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits<{
|
|
22
|
+
'select-route': [routeId: string]
|
|
23
|
+
}>()
|
|
24
|
+
|
|
25
|
+
const { getTree } = useApiIntrospection()
|
|
26
|
+
|
|
27
|
+
const items = ref<ApiTreeNode[]>([])
|
|
28
|
+
const loading = ref(true)
|
|
29
|
+
const error = ref<string | null>(null)
|
|
30
|
+
|
|
31
|
+
const search = ref('')
|
|
32
|
+
const expanded = ref<Set<string>>(new Set())
|
|
33
|
+
const activeRouteId = ref<string | undefined>()
|
|
34
|
+
|
|
35
|
+
// Same method filter as the Logs page toolbar.
|
|
36
|
+
const methodFilter = ref(ANY_FILTER)
|
|
37
|
+
|
|
38
|
+
const { t } = useI18n()
|
|
39
|
+
|
|
40
|
+
const methodOptions = computed(() =>
|
|
41
|
+
httpMethodFilterItems(t('page.api.filters.all_methods')),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
function methodAllowed(method: string): boolean {
|
|
45
|
+
if (methodFilter.value === ANY_FILTER) return true
|
|
46
|
+
return method.toUpperCase() === methodFilter.value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The health stats baked into the tree follow the page-level period selector.
|
|
50
|
+
// Immediate, so the first window to arrive is also the first one fetched; the
|
|
51
|
+
// panel shows its loading skeleton until then.
|
|
52
|
+
watch(() => props.period, () => void load(), { immediate: true })
|
|
53
|
+
|
|
54
|
+
// Filter a folder against the search query + active method chips. A leaf is
|
|
55
|
+
// kept when its method is allowed and the route path (the folder value) or
|
|
56
|
+
// the folder name matches the query. A folder is kept when it still has any
|
|
57
|
+
// leaf or sub-folder after filtering.
|
|
58
|
+
function filterFolder(folder: ApiTreeNode, q: string): ApiTreeNode | null {
|
|
59
|
+
const path = (folder.value ?? '').toLowerCase()
|
|
60
|
+
const label = folder.label.toLowerCase()
|
|
61
|
+
const pathMatch = !q || path.includes(q) || label.includes(q)
|
|
62
|
+
|
|
63
|
+
const leaves = (folder.children ?? [])
|
|
64
|
+
.filter((c) => !c.expandable)
|
|
65
|
+
.filter((leaf) => methodAllowed(leaf.label) && pathMatch)
|
|
66
|
+
|
|
67
|
+
const folders = (folder.children ?? [])
|
|
68
|
+
.filter((c) => c.expandable)
|
|
69
|
+
.map((f) => filterFolder(f, q))
|
|
70
|
+
.filter((f): f is ApiTreeNode => f !== null)
|
|
71
|
+
|
|
72
|
+
if (leaves.length === 0 && folders.length === 0) return null
|
|
73
|
+
return { ...folder, children: [...leaves, ...folders] }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const query = computed(() => search.value.trim().toLowerCase())
|
|
77
|
+
const forceExpand = computed(() => query.value.length > 0)
|
|
78
|
+
|
|
79
|
+
const displayTree = computed(() =>
|
|
80
|
+
items.value
|
|
81
|
+
.map((f) => filterFolder(f, query.value))
|
|
82
|
+
.filter((f): f is ApiTreeNode => f !== null),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
function firstLeafId(nodes: ApiTreeNode[]): string | undefined {
|
|
86
|
+
for (const node of nodes) {
|
|
87
|
+
if (!node.expandable && node.value) return node.value
|
|
88
|
+
if (node.children) {
|
|
89
|
+
const found = firstLeafId(node.children)
|
|
90
|
+
if (found) return found
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return undefined
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function load() {
|
|
97
|
+
const period = props.period
|
|
98
|
+
if (!period) return
|
|
99
|
+
loading.value = true
|
|
100
|
+
error.value = null
|
|
101
|
+
try {
|
|
102
|
+
items.value = await getTree(period)
|
|
103
|
+
// Open the first top folder and auto-select its first route, like the
|
|
104
|
+
// maquette which lands on the first leaf — but only on the first load.
|
|
105
|
+
// Reloads come from the page-header period control, and re-seeding here
|
|
106
|
+
// would collapse whatever the user had opened every time they change it.
|
|
107
|
+
if (!activeRouteId.value) {
|
|
108
|
+
const first = items.value[0]
|
|
109
|
+
if (first?.value) expanded.value = new Set([first.value])
|
|
110
|
+
const id = firstLeafId(items.value)
|
|
111
|
+
if (id) selectRoute(id)
|
|
112
|
+
}
|
|
113
|
+
} catch (e) {
|
|
114
|
+
error.value = e instanceof Error ? e.message : String(e)
|
|
115
|
+
} finally {
|
|
116
|
+
loading.value = false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function toggle(path: string) {
|
|
121
|
+
const next = new Set(expanded.value)
|
|
122
|
+
if (next.has(path)) next.delete(path)
|
|
123
|
+
else next.add(path)
|
|
124
|
+
expanded.value = next
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function selectRoute(routeId: string) {
|
|
128
|
+
activeRouteId.value = routeId
|
|
129
|
+
emit('select-route', routeId)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<template>
|
|
135
|
+
<div class="flex h-full w-full flex-col">
|
|
136
|
+
<!-- panel head -->
|
|
137
|
+
<div
|
|
138
|
+
class="flex items-center justify-between gap-2 border-b border-default px-4 py-3"
|
|
139
|
+
>
|
|
140
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
141
|
+
{{ $t('page.api.routes.tree_title') }}
|
|
142
|
+
</h2>
|
|
143
|
+
<UButton
|
|
144
|
+
icon="i-ph-arrow-clockwise"
|
|
145
|
+
size="xs"
|
|
146
|
+
color="neutral"
|
|
147
|
+
variant="ghost"
|
|
148
|
+
:loading="loading"
|
|
149
|
+
:aria-label="$t('page.api.routes.tree_refresh')"
|
|
150
|
+
@click="load"
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<!-- filter: search, then the method select below (same controls as the
|
|
155
|
+
Logs toolbar, minus status; the period lives in the page header) -->
|
|
156
|
+
<div class="flex flex-col gap-2 border-b border-default px-4 py-3">
|
|
157
|
+
<UInput
|
|
158
|
+
v-model="search"
|
|
159
|
+
icon="i-ph-magnifying-glass"
|
|
160
|
+
size="sm"
|
|
161
|
+
:placeholder="$t('page.api.routes.filter_placeholder')"
|
|
162
|
+
/>
|
|
163
|
+
<USelect v-model="methodFilter" :items="methodOptions" size="sm" class="w-full" />
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<!-- tree -->
|
|
167
|
+
<div class="min-h-0 flex-1 overflow-auto p-2">
|
|
168
|
+
<div v-if="error" class="px-2 py-3 text-sm text-error">{{ error }}</div>
|
|
169
|
+
|
|
170
|
+
<div v-else-if="loading" class="flex flex-col gap-1.5 p-1">
|
|
171
|
+
<USkeleton v-for="i in 8" :key="i" class="h-7 w-full" />
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div
|
|
175
|
+
v-else-if="displayTree.length === 0"
|
|
176
|
+
class="flex flex-col items-center gap-2 px-3 py-8 text-center text-dimmed"
|
|
177
|
+
>
|
|
178
|
+
<UIcon name="i-ph-funnel-x" class="size-6" />
|
|
179
|
+
<small>{{ $t('page.api.routes.no_match') }}</small>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<RouteTreeNode
|
|
183
|
+
v-for="folder in displayTree"
|
|
184
|
+
v-else
|
|
185
|
+
:key="folder.value ?? folder.label"
|
|
186
|
+
:node="folder"
|
|
187
|
+
:depth="0"
|
|
188
|
+
:expanded="expanded"
|
|
189
|
+
:force-expand="forceExpand"
|
|
190
|
+
:active-route-id="activeRouteId"
|
|
191
|
+
@toggle="toggle"
|
|
192
|
+
@select-route="selectRoute"
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</template>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import PeriodSelect from './internal/PeriodSelect.vue'
|
|
4
|
+
import RouteDetailTabs from './RouteDetailTabs.vue'
|
|
5
|
+
import RouteTree from './RouteTree.vue'
|
|
6
|
+
|
|
7
|
+
// v2 Routes page (DMS apiv2-routes): master-detail. Left a tree panel
|
|
8
|
+
// (folders + routes, filter, health dots); right the per-route detail with
|
|
9
|
+
// Statistics / Documentation / Tester / Configuration tabs. Composed from dms
|
|
10
|
+
// surfaces (DmsCard) so the theme is inherited.
|
|
11
|
+
const selectedRouteId = ref<string | null>(null)
|
|
12
|
+
|
|
13
|
+
// Stats window, from the period filter shared with the Overview and Logs
|
|
14
|
+
// pages. It drives both the tree health icons and the selected route's
|
|
15
|
+
// Statistics tab, and stays null until <PeriodSelect> resolves one so nothing
|
|
16
|
+
// fetches a window nobody picked.
|
|
17
|
+
const period = ref<string | null>(null)
|
|
18
|
+
|
|
19
|
+
function onRoute(id: string) {
|
|
20
|
+
selectedRouteId.value = id
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div class="flex h-full w-full flex-col gap-5 p-6">
|
|
26
|
+
<!-- page head -->
|
|
27
|
+
<header class="flex flex-wrap items-center gap-4">
|
|
28
|
+
<div
|
|
29
|
+
class="grid size-11 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary"
|
|
30
|
+
>
|
|
31
|
+
<UIcon name="i-ph-tree-structure" class="size-[22px]" />
|
|
32
|
+
</div>
|
|
33
|
+
<div class="min-w-0 flex-1">
|
|
34
|
+
<h1 class="text-2xl font-semibold tracking-tight text-highlighted">
|
|
35
|
+
{{ $t('page.api.routes.title') }}
|
|
36
|
+
</h1>
|
|
37
|
+
<p class="text-sm text-muted">
|
|
38
|
+
{{ $t('page.api.routes.description') }}
|
|
39
|
+
</p>
|
|
40
|
+
</div>
|
|
41
|
+
<PeriodSelect v-model="period" class="w-32" />
|
|
42
|
+
</header>
|
|
43
|
+
|
|
44
|
+
<!-- master-detail split -->
|
|
45
|
+
<div
|
|
46
|
+
class="grid min-h-0 flex-1 grid-cols-1 gap-5 lg:grid-cols-[minmax(280px,340px)_1fr]"
|
|
47
|
+
>
|
|
48
|
+
<!-- left: tree -->
|
|
49
|
+
<DmsCard
|
|
50
|
+
:padded="false"
|
|
51
|
+
class="flex max-h-[calc(100vh-13rem)] flex-col overflow-hidden"
|
|
52
|
+
>
|
|
53
|
+
<RouteTree :period="period" @select-route="onRoute" />
|
|
54
|
+
</DmsCard>
|
|
55
|
+
|
|
56
|
+
<!-- right: detail -->
|
|
57
|
+
<DmsCard
|
|
58
|
+
:padded="false"
|
|
59
|
+
class="max-h-[calc(100vh-13rem)] overflow-auto"
|
|
60
|
+
>
|
|
61
|
+
<RouteDetailTabs
|
|
62
|
+
v-if="selectedRouteId && period"
|
|
63
|
+
:key="selectedRouteId"
|
|
64
|
+
:route-id="selectedRouteId"
|
|
65
|
+
:period="period"
|
|
66
|
+
/>
|
|
67
|
+
<div
|
|
68
|
+
v-else
|
|
69
|
+
class="flex h-full min-h-[340px] flex-col items-center justify-center gap-2 px-6 text-center"
|
|
70
|
+
>
|
|
71
|
+
<UIcon name="i-ph-tree-structure" class="size-8 text-dimmed" />
|
|
72
|
+
<p class="text-base font-medium text-highlighted">
|
|
73
|
+
{{ $t('page.api.routes.placeholder.title') }}
|
|
74
|
+
</p>
|
|
75
|
+
<p class="max-w-md text-sm text-muted">
|
|
76
|
+
{{ $t('page.api.routes.placeholder.description') }}
|
|
77
|
+
</p>
|
|
78
|
+
</div>
|
|
79
|
+
</DmsCard>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type {
|
|
4
|
+
ChartDataPoint,
|
|
5
|
+
ChartResponse,
|
|
6
|
+
RouteStatsPayload,
|
|
7
|
+
} from '../composables/useApiIntrospection'
|
|
8
|
+
import ApiMethodBadge from './internal/ApiMethodBadge.vue'
|
|
9
|
+
import ApiStatusBadge from './internal/ApiStatusBadge.vue'
|
|
10
|
+
import UnitAreaChart from './internal/UnitAreaChart.vue'
|
|
11
|
+
import {
|
|
12
|
+
STATUS_CLASS_COLOR_BY_CATEGORY,
|
|
13
|
+
STATUS_CLASS_COLORS,
|
|
14
|
+
STATUS_CLASSES,
|
|
15
|
+
} from '../utils/statusClass'
|
|
16
|
+
|
|
17
|
+
// Statistics tab of a route detail (DMS apiv2-routes): four stat-cards +
|
|
18
|
+
// "Requests by status" / "Response time" area charts + recent-requests table.
|
|
19
|
+
const props = defineProps<{
|
|
20
|
+
stats: RouteStatsPayload
|
|
21
|
+
}>()
|
|
22
|
+
|
|
23
|
+
const { loadingDetailId, openLogDetail } = useLogDetailDrawer()
|
|
24
|
+
|
|
25
|
+
const aggregate = computed(() => props.stats.aggregate)
|
|
26
|
+
|
|
27
|
+
const kpis = computed(() => {
|
|
28
|
+
const a = aggregate.value
|
|
29
|
+
return {
|
|
30
|
+
requests: a?.requestsCount ?? 0,
|
|
31
|
+
avgLatencyMs: a ? Math.round(a.averageLatencyMs) : 0,
|
|
32
|
+
errorRate: a ? Math.round(a.errorRate * 10000) / 100 : 0,
|
|
33
|
+
maxLatencyMs: a ? Math.round(a.maxLatencyMs) : 0,
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// errorRate is expressed as a percentage here (see kpis above): 20% mirrors the
|
|
38
|
+
// backend "down" ratio (0.2), 5% the "elevated" ratio (0.05).
|
|
39
|
+
const ERROR_RATE_CRITICAL_PCT = 20
|
|
40
|
+
const ERROR_RATE_WARNING_PCT = 5
|
|
41
|
+
|
|
42
|
+
const errorTone = computed(() => {
|
|
43
|
+
const r = kpis.value.errorRate
|
|
44
|
+
if (r > ERROR_RATE_CRITICAL_PCT) return 'text-error'
|
|
45
|
+
if (r > ERROR_RATE_WARNING_PCT) return 'text-warning'
|
|
46
|
+
return 'text-highlighted'
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// The latency series are not status classes, so they carry their own accents;
|
|
50
|
+
// the min/max pair deliberately borrows the good/bad ends of STATUS_CLASSES.
|
|
51
|
+
const C_LATENCY = '#4dd9e6'
|
|
52
|
+
const C_BEST = STATUS_CLASSES[0].color
|
|
53
|
+
const C_WORST = STATUS_CLASSES[2].color
|
|
54
|
+
|
|
55
|
+
// Every latency the backend reports is in milliseconds (RouteStatistics stores
|
|
56
|
+
// `responseTime` in ms), so the whole Response time chart shares one unit.
|
|
57
|
+
const LATENCY_UNIT = 'ms'
|
|
58
|
+
|
|
59
|
+
function seriesByCategory(
|
|
60
|
+
payload: ChartResponse,
|
|
61
|
+
colors: Record<string, string>,
|
|
62
|
+
) {
|
|
63
|
+
const buckets = new Map<string, ChartDataPoint[]>()
|
|
64
|
+
for (const point of payload.data ?? []) {
|
|
65
|
+
const key = point.category ?? 'Other'
|
|
66
|
+
const list = buckets.get(key) ?? []
|
|
67
|
+
list.push(point)
|
|
68
|
+
buckets.set(key, list)
|
|
69
|
+
}
|
|
70
|
+
return [...buckets.entries()].map(([name, data]) => ({
|
|
71
|
+
name,
|
|
72
|
+
data: data.map((d) => ({ x: d.x, y: d.y })),
|
|
73
|
+
color: colors[name] ?? '#6b7280',
|
|
74
|
+
}))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The backend tags these points with the same category names STATUS_CLASSES
|
|
78
|
+
// carries, so the chart and the overview colour the same class identically.
|
|
79
|
+
const countsSeries = computed(() =>
|
|
80
|
+
seriesByCategory(props.stats.charts.counts, STATUS_CLASS_COLOR_BY_CATEGORY),
|
|
81
|
+
)
|
|
82
|
+
// The backend emits latency categories as Average/Min/Max; the legend must
|
|
83
|
+
// read Max, Average, Min.
|
|
84
|
+
const LATENCY_ORDER = ['Max', 'Average', 'Min']
|
|
85
|
+
const latencySeries = computed(() =>
|
|
86
|
+
seriesByCategory(props.stats.charts.latency, {
|
|
87
|
+
Average: C_LATENCY,
|
|
88
|
+
Min: C_BEST,
|
|
89
|
+
Max: C_WORST,
|
|
90
|
+
})
|
|
91
|
+
.sort(
|
|
92
|
+
(a, b) => LATENCY_ORDER.indexOf(a.name) - LATENCY_ORDER.indexOf(b.name),
|
|
93
|
+
)
|
|
94
|
+
.map((s) => ({
|
|
95
|
+
...s,
|
|
96
|
+
// Latency values carry many decimals; cap at 2 so the chart axis/tooltip
|
|
97
|
+
// stays readable.
|
|
98
|
+
data: s.data.map((p) => ({ ...p, y: Math.round(p.y * 100) / 100 })),
|
|
99
|
+
})),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
const hasCounts = computed(() =>
|
|
103
|
+
countsSeries.value.some((s) => s.data.some((p) => p.y > 0)),
|
|
104
|
+
)
|
|
105
|
+
const hasLatency = computed(() =>
|
|
106
|
+
latencySeries.value.some((s) => s.data.some((p) => p.y > 0)),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
function fmtTime(ts: string): string {
|
|
110
|
+
return new Date(ts).toLocaleTimeString()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<template>
|
|
116
|
+
<div class="flex w-full flex-col gap-5">
|
|
117
|
+
<!-- stat-cards -->
|
|
118
|
+
<div class="grid grid-cols-2 gap-4 lg:grid-cols-4">
|
|
119
|
+
<DmsCard class="flex flex-col gap-1.5">
|
|
120
|
+
<span class="font-mono text-[10px] uppercase tracking-widest text-dimmed">
|
|
121
|
+
{{ $t('page.api.routes.stats.kpi_requests') }}
|
|
122
|
+
</span>
|
|
123
|
+
<span class="text-2xl font-semibold text-highlighted">
|
|
124
|
+
{{ kpis.requests.toLocaleString() }}
|
|
125
|
+
</span>
|
|
126
|
+
</DmsCard>
|
|
127
|
+
<DmsCard class="flex flex-col gap-1.5">
|
|
128
|
+
<span class="font-mono text-[10px] uppercase tracking-widest text-dimmed">
|
|
129
|
+
{{ $t('page.api.routes.stats.kpi_avg_latency') }}
|
|
130
|
+
</span>
|
|
131
|
+
<span class="text-2xl font-semibold text-highlighted">
|
|
132
|
+
{{ kpis.avgLatencyMs }}<span class="text-sm font-normal text-muted"> ms</span>
|
|
133
|
+
</span>
|
|
134
|
+
</DmsCard>
|
|
135
|
+
<DmsCard class="flex flex-col gap-1.5">
|
|
136
|
+
<span class="font-mono text-[10px] uppercase tracking-widest text-dimmed">
|
|
137
|
+
{{ $t('page.api.routes.stats.kpi_error_rate') }}
|
|
138
|
+
</span>
|
|
139
|
+
<span class="text-2xl font-semibold" :class="errorTone">
|
|
140
|
+
{{ kpis.errorRate }}%
|
|
141
|
+
</span>
|
|
142
|
+
</DmsCard>
|
|
143
|
+
<DmsCard class="flex flex-col gap-1.5">
|
|
144
|
+
<span class="font-mono text-[10px] uppercase tracking-widest text-dimmed">
|
|
145
|
+
{{ $t('page.api.routes.stats.kpi_max_latency') }}
|
|
146
|
+
</span>
|
|
147
|
+
<span class="text-2xl font-semibold text-highlighted">
|
|
148
|
+
{{ kpis.maxLatencyMs }}<span class="text-sm font-normal text-muted"> ms</span>
|
|
149
|
+
</span>
|
|
150
|
+
</DmsCard>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<!-- charts -->
|
|
154
|
+
<div class="grid grid-cols-1 gap-4 xl:grid-cols-2">
|
|
155
|
+
<DmsCard :padded="false" class="overflow-hidden">
|
|
156
|
+
<div class="px-5 pt-4">
|
|
157
|
+
<h3 class="text-sm font-semibold text-highlighted">
|
|
158
|
+
{{ $t('page.api.routes.stats.chart_counts_title') }}
|
|
159
|
+
</h3>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="px-2 pb-2 pt-2">
|
|
162
|
+
<DmsChart
|
|
163
|
+
v-if="hasCounts"
|
|
164
|
+
type="area"
|
|
165
|
+
:static-dataset="countsSeries"
|
|
166
|
+
:smooth="true"
|
|
167
|
+
:show-legend="true"
|
|
168
|
+
:color="STATUS_CLASS_COLORS"
|
|
169
|
+
height="240px"
|
|
170
|
+
/>
|
|
171
|
+
<div
|
|
172
|
+
v-else
|
|
173
|
+
class="flex flex-col items-center justify-center gap-2 text-dimmed"
|
|
174
|
+
style="height: 240px"
|
|
175
|
+
>
|
|
176
|
+
<UIcon name="i-ph-chart-line" class="size-6" />
|
|
177
|
+
<small>{{ $t('page.api.routes.stats.chart_empty') }}</small>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</DmsCard>
|
|
181
|
+
|
|
182
|
+
<DmsCard :padded="false" class="overflow-hidden">
|
|
183
|
+
<div class="px-5 pt-4">
|
|
184
|
+
<h3 class="text-sm font-semibold text-highlighted">
|
|
185
|
+
{{ $t('page.api.routes.stats.chart_latency_title') }}
|
|
186
|
+
</h3>
|
|
187
|
+
</div>
|
|
188
|
+
<div class="px-2 pb-2 pt-2">
|
|
189
|
+
<UnitAreaChart
|
|
190
|
+
v-if="hasLatency"
|
|
191
|
+
:series="latencySeries"
|
|
192
|
+
:unit="LATENCY_UNIT"
|
|
193
|
+
:colors="[C_WORST, C_LATENCY, C_BEST]"
|
|
194
|
+
height="240px"
|
|
195
|
+
/>
|
|
196
|
+
<div
|
|
197
|
+
v-else
|
|
198
|
+
class="flex flex-col items-center justify-center gap-2 text-dimmed"
|
|
199
|
+
style="height: 240px"
|
|
200
|
+
>
|
|
201
|
+
<UIcon name="i-ph-chart-line" class="size-6" />
|
|
202
|
+
<small>{{ $t('page.api.routes.stats.chart_empty') }}</small>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</DmsCard>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<!-- recent requests -->
|
|
209
|
+
<DmsCard :padded="false" class="overflow-hidden">
|
|
210
|
+
<div class="border-b border-default px-5 py-3.5">
|
|
211
|
+
<h3 class="text-sm font-semibold text-highlighted">
|
|
212
|
+
{{ $t('page.api.routes.stats.recent_title') }}
|
|
213
|
+
</h3>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<div
|
|
217
|
+
v-if="stats.recent.length === 0"
|
|
218
|
+
class="flex flex-col items-center gap-2 px-6 py-8 text-center text-dimmed"
|
|
219
|
+
>
|
|
220
|
+
<UIcon name="i-ph-clock-counter-clockwise" class="size-6" />
|
|
221
|
+
<small>{{ $t('page.api.routes.stats.recent_empty_title') }}</small>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div v-else class="overflow-x-auto">
|
|
225
|
+
<table class="w-full text-sm">
|
|
226
|
+
<thead>
|
|
227
|
+
<tr
|
|
228
|
+
class="border-b border-default text-left font-mono text-[10px] uppercase tracking-widest text-dimmed"
|
|
229
|
+
>
|
|
230
|
+
<th class="px-5 py-2.5">{{ $t('page.api.routes.stats.col_time') }}</th>
|
|
231
|
+
<th class="px-2 py-2.5">{{ $t('page.api.routes.stats.col_method') }}</th>
|
|
232
|
+
<th class="px-2 py-2.5">{{ $t('page.api.routes.stats.col_path') }}</th>
|
|
233
|
+
<th class="px-2 py-2.5">{{ $t('page.api.routes.stats.col_status') }}</th>
|
|
234
|
+
<th class="px-5 py-2.5 text-right">{{ $t('page.api.routes.stats.col_ms') }}</th>
|
|
235
|
+
</tr>
|
|
236
|
+
</thead>
|
|
237
|
+
<tbody>
|
|
238
|
+
<tr
|
|
239
|
+
v-for="row in stats.recent"
|
|
240
|
+
:key="row._id"
|
|
241
|
+
class="cursor-pointer border-b border-default/60 last:border-0 hover:bg-elevated/40"
|
|
242
|
+
@click="openLogDetail(row)"
|
|
243
|
+
>
|
|
244
|
+
<td class="px-5 py-2 font-mono text-xs text-muted">
|
|
245
|
+
{{ fmtTime(row.timestamp) }}
|
|
246
|
+
</td>
|
|
247
|
+
<td class="px-2 py-2">
|
|
248
|
+
<ApiMethodBadge :method="row.method" />
|
|
249
|
+
</td>
|
|
250
|
+
<td class="px-2 py-2 font-mono text-xs text-toned">{{ row.uri }}</td>
|
|
251
|
+
<td class="px-2 py-2">
|
|
252
|
+
<ApiStatusBadge :status="row.statusCode" />
|
|
253
|
+
</td>
|
|
254
|
+
<td class="px-5 py-2 text-right font-mono text-xs text-muted">
|
|
255
|
+
{{ Math.round(row.responseTimeMs) }}
|
|
256
|
+
<UIcon
|
|
257
|
+
v-if="loadingDetailId === row._id"
|
|
258
|
+
name="i-ph-spinner"
|
|
259
|
+
class="ml-1 animate-spin"
|
|
260
|
+
/>
|
|
261
|
+
</td>
|
|
262
|
+
</tr>
|
|
263
|
+
</tbody>
|
|
264
|
+
</table>
|
|
265
|
+
</div>
|
|
266
|
+
</DmsCard>
|
|
267
|
+
</div>
|
|
268
|
+
</template>
|