@antelopejs/dms-api 0.1.7 → 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.
- package/README.md +99 -8
- package/dist/automation/get-api-health.js +4 -3
- package/dist/automation/get-api-health.js.map +1 -1
- package/dist/automation/route-unhealthy.js +2 -2
- package/dist/automation/route-unhealthy.js.map +1 -1
- package/dist/automation/scope.d.ts +0 -1
- package/dist/automation/scope.js +0 -7
- package/dist/automation/scope.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +15 -9
- package/dist/config.js.map +1 -1
- package/dist/db/models/request_log.model.d.ts +37 -2
- package/dist/db/models/request_log.model.js +130 -35
- package/dist/db/models/request_log.model.js.map +1 -1
- package/dist/db/models/request_log.search.d.ts +5 -0
- package/dist/db/models/request_log.search.js +35 -0
- package/dist/db/models/request_log.search.js.map +1 -0
- package/dist/db/models/request_log.status.d.ts +5 -0
- package/dist/db/models/request_log.status.js +9 -0
- package/dist/db/models/request_log.status.js.map +1 -0
- package/dist/db/models/routes.model.d.ts +1 -0
- package/dist/db/models/routes.model.js +5 -1
- package/dist/db/models/routes.model.js.map +1 -1
- package/dist/db/models/routes_statistics.model.js +1 -1
- package/dist/db/models/routes_statistics.model.js.map +1 -1
- package/dist/db/tables/api_settings.table.d.ts +1 -0
- package/dist/db/tables/api_settings.table.js +4 -0
- package/dist/db/tables/api_settings.table.js.map +1 -1
- package/dist/db/tables/request_log.table.d.ts +18 -3
- package/dist/db/tables/request_log.table.js +34 -1
- package/dist/db/tables/request_log.table.js.map +1 -1
- package/dist/db/tables/routes.table.d.ts +1 -2
- package/dist/db/tables/routes.table.js.map +1 -1
- package/dist/db/tables/routes_statistics.table.d.ts +4 -3
- package/dist/db/tables/routes_statistics.table.js +5 -1
- package/dist/db/tables/routes_statistics.table.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/memo.d.ts +5 -0
- package/dist/memo.js +36 -0
- package/dist/memo.js.map +1 -0
- package/dist/pages/blocks.d.ts +3 -0
- package/dist/pages/blocks.js +31 -0
- package/dist/pages/blocks.js.map +1 -0
- package/dist/pages/displays.d.ts +7 -0
- package/dist/pages/displays.js +23 -0
- package/dist/pages/displays.js.map +1 -0
- package/dist/pages/index.d.ts +5 -2
- package/dist/pages/index.js +5 -2
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/logs.d.ts +18 -0
- package/dist/pages/logs.js +112 -0
- package/dist/pages/logs.js.map +1 -0
- package/dist/pages/module.d.ts +3 -0
- package/dist/pages/module.js +102 -6
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.d.ts +14 -0
- package/dist/pages/overview.js +215 -0
- package/dist/pages/overview.js.map +1 -0
- package/dist/pages/period.d.ts +9 -0
- package/dist/pages/period.js +24 -0
- package/dist/pages/period.js.map +1 -0
- package/dist/pages/request-table.d.ts +11 -0
- package/dist/pages/request-table.js +187 -0
- package/dist/pages/request-table.js.map +1 -0
- package/dist/pages/routes.d.ts +15 -0
- package/dist/pages/routes.js +269 -0
- package/dist/pages/routes.js.map +1 -0
- package/dist/pages/scope-chip.d.ts +9 -0
- package/dist/pages/scope-chip.js +28 -0
- package/dist/pages/scope-chip.js.map +1 -0
- package/dist/pages/{logs/page.d.ts → settings.d.ts} +3 -3
- package/dist/pages/settings.js +218 -0
- package/dist/pages/settings.js.map +1 -0
- package/dist/pages/toolbar.d.ts +9 -0
- package/dist/pages/toolbar.js +33 -0
- package/dist/pages/toolbar.js.map +1 -0
- package/dist/realtime.d.ts +2 -0
- package/dist/realtime.js +21 -0
- package/dist/realtime.js.map +1 -0
- package/dist/routes/index.d.ts +2 -2
- package/dist/routes/index.js +2 -2
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/logs.d.ts +173 -2
- package/dist/routes/logs.js +177 -86
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/overview.d.ts +27 -0
- package/dist/routes/overview.js +131 -0
- package/dist/routes/overview.js.map +1 -0
- package/dist/routes/routes.d.ts +92 -28
- package/dist/routes/routes.js +165 -97
- package/dist/routes/routes.js.map +1 -1
- package/dist/routes/settings.d.ts +16 -11
- package/dist/routes/settings.js +62 -54
- package/dist/routes/settings.js.map +1 -1
- package/dist/routes/tester.d.ts +7 -0
- package/dist/routes/tester.js +34 -0
- package/dist/routes/tester.js.map +1 -0
- package/dist/services/activity.d.ts +49 -0
- package/dist/services/activity.js +207 -0
- package/dist/services/activity.js.map +1 -0
- package/dist/services/aggregate-cache.d.ts +3 -0
- package/dist/services/aggregate-cache.js +16 -0
- package/dist/services/aggregate-cache.js.map +1 -0
- package/dist/services/api-origin.d.ts +1 -0
- package/dist/services/api-origin.js +9 -0
- package/dist/services/api-origin.js.map +1 -0
- package/dist/services/attention.d.ts +45 -0
- package/dist/services/attention.js +203 -0
- package/dist/services/attention.js.map +1 -0
- package/dist/services/composed-text.d.ts +6 -0
- package/dist/services/composed-text.js +23 -0
- package/dist/services/composed-text.js.map +1 -0
- package/dist/services/health-rules.d.ts +49 -0
- package/dist/services/health-rules.js +233 -0
- package/dist/services/health-rules.js.map +1 -0
- package/dist/services/index.d.ts +1 -3
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +1 -1
- package/dist/services/introspection/decorators.d.ts +14 -0
- package/dist/services/introspection/decorators.js +192 -0
- package/dist/services/introspection/decorators.js.map +1 -0
- package/dist/services/introspection/errors.js +4 -4
- package/dist/services/introspection/errors.js.map +1 -1
- package/dist/services/introspection/index.d.ts +6 -8
- package/dist/services/introspection/index.js +96 -32
- package/dist/services/introspection/index.js.map +1 -1
- package/dist/services/introspection/probe.d.ts +2 -1
- package/dist/services/introspection/probe.js +11 -0
- package/dist/services/introspection/probe.js.map +1 -1
- package/dist/services/links.d.ts +25 -0
- package/dist/services/links.js +72 -0
- package/dist/services/links.js.map +1 -0
- package/dist/services/live-feed.d.ts +6 -0
- package/dist/services/live-feed.js +18 -0
- package/dist/services/live-feed.js.map +1 -0
- package/dist/services/live.d.ts +16 -0
- package/dist/services/live.js +32 -0
- package/dist/services/live.js.map +1 -0
- package/dist/services/overview.d.ts +122 -0
- package/dist/services/overview.js +324 -0
- package/dist/services/overview.js.map +1 -0
- package/dist/services/period.d.ts +0 -9
- package/dist/services/period.js +5 -52
- package/dist/services/period.js.map +1 -1
- package/dist/services/request-log/access.d.ts +5 -0
- package/dist/services/request-log/access.js +21 -0
- package/dist/services/request-log/access.js.map +1 -0
- package/dist/services/request-log/capture.d.ts +30 -0
- package/dist/services/request-log/capture.js +216 -39
- package/dist/services/request-log/capture.js.map +1 -1
- package/dist/services/request-log/list.d.ts +36 -0
- package/dist/services/request-log/list.js +201 -0
- package/dist/services/request-log/list.js.map +1 -0
- package/dist/services/request-log/read.d.ts +15 -2
- package/dist/services/request-log/read.js +47 -4
- package/dist/services/request-log/read.js.map +1 -1
- package/dist/services/request-log/redaction.d.ts +16 -3
- package/dist/services/request-log/redaction.js +149 -27
- package/dist/services/request-log/redaction.js.map +1 -1
- package/dist/services/request-log/util.d.ts +10 -3
- package/dist/services/request-log/util.js +39 -22
- package/dist/services/request-log/util.js.map +1 -1
- package/dist/services/route-catalog.d.ts +62 -0
- package/dist/services/route-catalog.js +163 -0
- package/dist/services/route-catalog.js.map +1 -0
- package/dist/services/route-contract.d.ts +66 -0
- package/dist/services/route-contract.js +266 -0
- package/dist/services/route-contract.js.map +1 -0
- package/dist/services/route-health.d.ts +35 -0
- package/dist/services/route-health.js +179 -0
- package/dist/services/route-health.js.map +1 -0
- package/dist/services/route-statistics.d.ts +68 -0
- package/dist/services/route-statistics.js +277 -0
- package/dist/services/route-statistics.js.map +1 -0
- package/dist/services/routes-sync.d.ts +7 -3
- package/dist/services/routes-sync.js +96 -20
- package/dist/services/routes-sync.js.map +1 -1
- package/dist/services/scope.d.ts +0 -1
- package/dist/services/scope.js +4 -17
- package/dist/services/scope.js.map +1 -1
- package/dist/services/settings-form.d.ts +131 -0
- package/dist/services/settings-form.js +210 -0
- package/dist/services/settings-form.js.map +1 -0
- package/dist/services/settings.d.ts +2 -0
- package/dist/services/settings.js +5 -0
- package/dist/services/settings.js.map +1 -1
- package/dist/services/statistics-aggregate.d.ts +6 -41
- package/dist/services/statistics-aggregate.js +55 -280
- package/dist/services/statistics-aggregate.js.map +1 -1
- package/dist/services/statistics-utils.d.ts +7 -12
- package/dist/services/statistics-utils.js +36 -51
- package/dist/services/statistics-utils.js.map +1 -1
- package/dist/services/statistics-write.js +64 -22
- package/dist/services/statistics-write.js.map +1 -1
- package/dist/services/tester-source.d.ts +11 -0
- package/dist/services/tester-source.js +48 -0
- package/dist/services/tester-source.js.map +1 -0
- package/dist/services/traffic-samples.d.ts +18 -0
- package/dist/services/traffic-samples.js +134 -0
- package/dist/services/traffic-samples.js.map +1 -0
- package/dist/services/traffic.d.ts +43 -0
- package/dist/services/traffic.js +270 -0
- package/dist/services/traffic.js.map +1 -0
- package/dist/services/window.d.ts +48 -0
- package/dist/services/window.js +179 -0
- package/dist/services/window.js.map +1 -0
- package/dist/types/constants.d.ts +11 -20
- package/dist/types/constants.js +15 -25
- package/dist/types/constants.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/statistics.d.ts +5 -3
- package/dist/types/statistics.js +5 -0
- package/dist/types/statistics.js.map +1 -1
- package/frontend-vue/app/components/blocks/BetaBadge.vue +20 -0
- package/frontend-vue/app/components/blocks/HealthHero.vue +708 -0
- package/frontend-vue/app/components/blocks/LiveTraffic.vue +356 -0
- package/frontend-vue/app/components/blocks/LogsEmptyState.vue +228 -0
- package/frontend-vue/app/components/blocks/LogsFilters.vue +279 -0
- package/frontend-vue/app/components/blocks/RequestDetail.vue +722 -0
- package/frontend-vue/app/components/blocks/RetentionInput.vue +227 -0
- package/frontend-vue/app/components/blocks/RouteDocumentation.vue +611 -0
- package/frontend-vue/app/components/blocks/RouteHeader.vue +320 -0
- package/frontend-vue/app/components/blocks/RouteTester.vue +1879 -0
- package/frontend-vue/app/components/blocks/RouteTree.vue +676 -0
- package/frontend-vue/app/components/blocks/ScopeChip.vue +89 -0
- package/frontend-vue/app/components/blocks/SettingNumberInput.vue +65 -0
- package/frontend-vue/app/components/blocks/SplitLayout.vue +41 -0
- package/frontend-vue/app/components/internal/ApiBody.vue +129 -0
- package/frontend-vue/app/components/internal/ApiJsonTree.vue +82 -0
- package/frontend-vue/app/components/internal/ApiKeyValues.vue +41 -0
- package/frontend-vue/app/components/internal/ApiMethodBadge.vue +19 -19
- package/frontend-vue/app/components/internal/ApiPath.vue +33 -0
- package/frontend-vue/app/components/internal/ApiStatusBadge.vue +20 -15
- package/frontend-vue/app/components/internal/ApiTesterBadge.vue +17 -0
- package/frontend-vue/app/composables/useApiOrigin.ts +19 -0
- package/frontend-vue/app/composables/useApiPeriod.ts +19 -0
- package/frontend-vue/app/composables/useApiResource.ts +92 -0
- package/frontend-vue/app/composables/useDateFormat.ts +23 -0
- package/frontend-vue/app/composables/useLiveMissedErrors.ts +33 -0
- package/frontend-vue/app/composables/useRouteDetail.ts +253 -0
- package/frontend-vue/app/composables/useRouteSelection.ts +43 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +30 -0
- package/frontend-vue/app/plugins/displays.ts +92 -0
- package/frontend-vue/app/utils/format.ts +281 -0
- package/frontend-vue/app/utils/http.ts +127 -0
- package/frontend-vue/app/utils/logsQuery.ts +261 -0
- package/frontend-vue/app/utils/minuteHistogram.ts +116 -0
- package/frontend-vue/app/utils/requestDrawer.ts +257 -0
- package/frontend-vue/app/utils/routeExplorer.ts +206 -0
- package/frontend-vue/app/utils/search.ts +45 -0
- package/frontend-vue/app/utils/settingsForm.ts +119 -0
- package/frontend-vue/app/utils/snippets.ts +501 -0
- package/frontend-vue/app/utils/testerHistory.ts +354 -0
- package/frontend-vue/app/utils/testerRequest.ts +632 -11
- package/frontend-vue/dms.frontend.build.ts +7 -0
- package/frontend-vue/dms.frontend.ts +10 -3
- package/frontend-vue/i18n/locales/api-en-GB.json +866 -0
- package/frontend-vue/i18n/locales/api-fr-FR.json +866 -0
- package/frontend-vue/package.json +2 -6
- package/frontend-vue/pnpm-lock.yaml +97 -3375
- package/frontend-vue/tests/format.test.ts +180 -0
- package/frontend-vue/tests/http.test.ts +61 -0
- package/frontend-vue/tests/logsQuery.test.ts +255 -0
- package/frontend-vue/tests/minuteHistogram.test.ts +94 -0
- package/frontend-vue/tests/registration.test.ts +24 -7
- package/frontend-vue/tests/requestDrawer.test.ts +179 -0
- package/frontend-vue/tests/routeExplorer.test.ts +206 -0
- package/frontend-vue/tests/settingsForm.test.ts +155 -0
- package/frontend-vue/tests/snippets.test.ts +285 -0
- package/frontend-vue/tests/testerHistory.test.ts +295 -0
- package/frontend-vue/tests/testerRequest.test.ts +471 -76
- package/frontend-vue/tests/tooltipTriggers.test.ts +51 -0
- package/package.json +8 -8
- package/dist/middlewares/index.d.ts +0 -1
- package/dist/middlewares/index.js +0 -18
- package/dist/middlewares/index.js.map +0 -1
- package/dist/middlewares/request-log-capture.d.ts +0 -1
- package/dist/middlewares/request-log-capture.js +0 -6
- package/dist/middlewares/request-log-capture.js.map +0 -1
- package/dist/pages/all.d.ts +0 -4
- package/dist/pages/all.js +0 -21
- package/dist/pages/all.js.map +0 -1
- package/dist/pages/logs/page.js +0 -29
- package/dist/pages/logs/page.js.map +0 -1
- package/dist/pages/routes/page.d.ts +0 -9
- package/dist/pages/routes/page.js +0 -29
- package/dist/pages/routes/page.js.map +0 -1
- package/dist/pages/settings/form.d.ts +0 -3
- package/dist/pages/settings/form.js +0 -80
- package/dist/pages/settings/form.js.map +0 -1
- package/dist/pages/settings/page.d.ts +0 -9
- package/dist/pages/settings/page.js +0 -26
- package/dist/pages/settings/page.js.map +0 -1
- package/dist/pages/summary/page.d.ts +0 -9
- package/dist/pages/summary/page.js +0 -29
- package/dist/pages/summary/page.js.map +0 -1
- package/dist/routes/monitoring.d.ts +0 -17
- package/dist/routes/monitoring.js +0 -101
- package/dist/routes/monitoring.js.map +0 -1
- package/dist/routes/summary.d.ts +0 -32
- package/dist/routes/summary.js +0 -181
- package/dist/routes/summary.js.map +0 -1
- package/dist/services/request-log/index.d.ts +0 -3
- package/dist/services/request-log/index.js +0 -12
- package/dist/services/request-log/index.js.map +0 -1
- package/dist/services/statistics-read.d.ts +0 -4
- package/dist/services/statistics-read.js +0 -48
- package/dist/services/statistics-read.js.map +0 -1
- package/dist/services/tree.d.ts +0 -10
- package/dist/services/tree.js +0 -128
- package/dist/services/tree.js.map +0 -1
- package/dist/types/charts.d.ts +0 -9
- package/dist/types/charts.js +0 -3
- package/dist/types/charts.js.map +0 -1
- package/frontend-vue/app/components/ConfigurationView.vue +0 -187
- package/frontend-vue/app/components/DocumentationView.vue +0 -224
- package/frontend-vue/app/components/LogDetailDrawer.vue +0 -178
- package/frontend-vue/app/components/LogsView.vue +0 -347
- package/frontend-vue/app/components/RouteDetailTabs.vue +0 -179
- package/frontend-vue/app/components/RouteTree.vue +0 -196
- package/frontend-vue/app/components/RoutesView.vue +0 -79
- package/frontend-vue/app/components/StatsView.vue +0 -268
- package/frontend-vue/app/components/SummaryView.vue +0 -657
- package/frontend-vue/app/components/TesterPanel.vue +0 -499
- package/frontend-vue/app/components/internal/PeriodSelect.vue +0 -58
- package/frontend-vue/app/components/internal/RouteTreeNode.vue +0 -168
- package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +0 -162
- package/frontend-vue/app/components/internal/StatusDonut.vue +0 -84
- package/frontend-vue/app/components/internal/UnitAreaChart.vue +0 -73
- package/frontend-vue/app/composables/useApiIntrospection.ts +0 -350
- package/frontend-vue/app/composables/useLogDetailDrawer.ts +0 -50
- package/frontend-vue/app/composables/useSelectedPeriod.ts +0 -107
- package/frontend-vue/app/composables/useStatsPeriods.ts +0 -139
- 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 +0 -49
- package/frontend-vue/app/utils/statusClass.ts +0 -49
- package/frontend-vue/i18n/locales/en-GB.json +0 -240
- package/frontend-vue/i18n/locales/fr-FR.json +0 -240
- package/frontend-vue/public/.gitkeep +0 -0
- package/frontend-vue/server/.gitkeep +0 -0
- package/frontend-vue/tests/periods.test.ts +0 -145
- package/frontend-vue/tests/persistence.test.ts +0 -45
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Frontend introspection facade.
|
|
3
|
-
*
|
|
4
|
-
* Single composable wrapping every /api/monitoring/* fetch the new pages need.
|
|
5
|
-
* Mirrors the backend's `src/services/introspection` swap-point: when
|
|
6
|
-
* the runtime gains real introspection and endpoint shapes change,
|
|
7
|
-
* only this file needs updating.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// --- Shapes mirrored from the backend ---------------------------------------
|
|
11
|
-
|
|
12
|
-
export type ParameterSource =
|
|
13
|
-
| 'body'
|
|
14
|
-
| 'query'
|
|
15
|
-
| 'param'
|
|
16
|
-
| 'header'
|
|
17
|
-
| 'context'
|
|
18
|
-
| 'result'
|
|
19
|
-
| 'raw'
|
|
20
|
-
| 'stream'
|
|
21
|
-
| 'connection'
|
|
22
|
-
| 'unknown'
|
|
23
|
-
|
|
24
|
-
export type InferredType =
|
|
25
|
-
| 'string'
|
|
26
|
-
| 'number'
|
|
27
|
-
| 'boolean'
|
|
28
|
-
| 'object'
|
|
29
|
-
| 'buffer'
|
|
30
|
-
| 'stream'
|
|
31
|
-
| 'unknown'
|
|
32
|
-
|
|
33
|
-
export interface ParameterInfo {
|
|
34
|
-
index: number
|
|
35
|
-
name: string | null
|
|
36
|
-
source: ParameterSource
|
|
37
|
-
multi: boolean
|
|
38
|
-
inferredType: InferredType
|
|
39
|
-
modifierCount: number
|
|
40
|
-
rawProviderSource?: string
|
|
41
|
-
hint?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PropertyInfo {
|
|
45
|
-
key: string
|
|
46
|
-
decorator: string
|
|
47
|
-
modifierCount: number
|
|
48
|
-
rawProviderSource?: string
|
|
49
|
-
hint?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type MiddlewareMode = 'prefix' | 'postfix' | 'monitor'
|
|
53
|
-
|
|
54
|
-
export interface MiddlewareInfo {
|
|
55
|
-
id: string
|
|
56
|
-
mode: MiddlewareMode
|
|
57
|
-
location: string
|
|
58
|
-
method: string
|
|
59
|
-
callbackName: string
|
|
60
|
-
priority?: number
|
|
61
|
-
isAuth: boolean
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface InferredErrorCode {
|
|
65
|
-
status: number
|
|
66
|
-
reason: string | null
|
|
67
|
-
source: 'assert' | 'HTTPResult'
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type RouteHandlerMode =
|
|
71
|
-
| 'handler'
|
|
72
|
-
| 'prefix'
|
|
73
|
-
| 'postfix'
|
|
74
|
-
| 'monitor'
|
|
75
|
-
| 'websocket'
|
|
76
|
-
|
|
77
|
-
export interface RouteInspection {
|
|
78
|
-
id: string
|
|
79
|
-
location: string
|
|
80
|
-
method: string
|
|
81
|
-
mode: RouteHandlerMode
|
|
82
|
-
callbackName: string
|
|
83
|
-
priority?: number
|
|
84
|
-
parameters: ParameterInfo[]
|
|
85
|
-
properties: PropertyInfo[]
|
|
86
|
-
applicableMiddleware: MiddlewareInfo[]
|
|
87
|
-
errorCodes: InferredErrorCode[]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface RouteDocPayload extends RouteInspection {
|
|
91
|
-
registeredAt: string | null
|
|
92
|
-
updatedAt: string | null
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface FolderInspection {
|
|
96
|
-
path: string
|
|
97
|
-
middlewareAtOrAbove: MiddlewareInfo[]
|
|
98
|
-
routes: RouteInspection[]
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface TreeNodeStats {
|
|
102
|
-
requestsCount: number
|
|
103
|
-
errorRate: number
|
|
104
|
-
slow: boolean
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface ApiTreeNode {
|
|
108
|
-
label: string
|
|
109
|
-
value?: string
|
|
110
|
-
icon?: string
|
|
111
|
-
expandable?: boolean
|
|
112
|
-
selectable?: boolean
|
|
113
|
-
children?: ApiTreeNode[]
|
|
114
|
-
customData?: TreeNodeStats
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface ChartDataPoint {
|
|
118
|
-
x: string
|
|
119
|
-
y: number
|
|
120
|
-
label?: string
|
|
121
|
-
category?: string
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Payload shape of the dms-api statistics chart endpoints. Deliberately not
|
|
126
|
-
* named `ChartResponse`: the DMS UI layer exports an unrelated `ChartResponse`
|
|
127
|
-
* (`{ series: ChartSeries[] }`) under that name, and the two would shadow each
|
|
128
|
-
* other across layers.
|
|
129
|
-
*/
|
|
130
|
-
export interface ApiChartResponse {
|
|
131
|
-
data?: ChartDataPoint[]
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface RouteAggregate {
|
|
135
|
-
routeKey: string
|
|
136
|
-
method: string
|
|
137
|
-
uri: string
|
|
138
|
-
requestsCount: number
|
|
139
|
-
averageLatencyMs: number
|
|
140
|
-
minLatencyMs: number
|
|
141
|
-
maxLatencyMs: number
|
|
142
|
-
errorsClient: number
|
|
143
|
-
errorsServer: number
|
|
144
|
-
errorRate: number
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface RequestLogSummary {
|
|
148
|
-
_id: string
|
|
149
|
-
timestamp: string
|
|
150
|
-
method: string
|
|
151
|
-
uri: string
|
|
152
|
-
rawPath: string
|
|
153
|
-
routeId?: string
|
|
154
|
-
statusCode: number
|
|
155
|
-
responseTimeMs: number
|
|
156
|
-
ip?: string
|
|
157
|
-
userAgent?: string
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface RouteStatsPayload {
|
|
161
|
-
route: { id: string; location: string; method: string }
|
|
162
|
-
aggregate?: RouteAggregate
|
|
163
|
-
charts: {
|
|
164
|
-
counts: ApiChartResponse
|
|
165
|
-
latency: ApiChartResponse
|
|
166
|
-
}
|
|
167
|
-
recent: RequestLogSummary[]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export interface SummaryKpis {
|
|
171
|
-
totalRoutes: number
|
|
172
|
-
routesWithErrors24h: number
|
|
173
|
-
slowRoutesCount: number
|
|
174
|
-
averageLatencyMs: number
|
|
175
|
-
callsToday: number
|
|
176
|
-
errors24h: number
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface SummaryPayload {
|
|
180
|
-
kpis: SummaryKpis
|
|
181
|
-
autoGeneratedCount: number
|
|
182
|
-
customCount: number
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export interface HistoryPoint {
|
|
186
|
-
day: number
|
|
187
|
-
label: string
|
|
188
|
-
success: number
|
|
189
|
-
clientErrors: number
|
|
190
|
-
serverErrors: number
|
|
191
|
-
slow: number
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface StatusBreakdown {
|
|
195
|
-
success: number
|
|
196
|
-
clientErrors: number
|
|
197
|
-
serverErrors: number
|
|
198
|
-
total: number
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export type WatchListFlag = 'broken' | 'slow' | 'warn'
|
|
202
|
-
|
|
203
|
-
export interface WatchListItem {
|
|
204
|
-
routeKey: string
|
|
205
|
-
method: string
|
|
206
|
-
uri: string
|
|
207
|
-
errorRate: number
|
|
208
|
-
averageLatencyMs: number
|
|
209
|
-
requestsLast24h: number
|
|
210
|
-
flag: WatchListFlag
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export type ActivityKind = 'route-created' | 'error'
|
|
214
|
-
|
|
215
|
-
export interface ActivityItem {
|
|
216
|
-
kind: ActivityKind
|
|
217
|
-
timestamp: string
|
|
218
|
-
method: string
|
|
219
|
-
uri: string
|
|
220
|
-
statusCode?: number
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface MonitoringPayload {
|
|
224
|
-
period: { granularity: 'minute' | 'hour' | 'day'; count: number }
|
|
225
|
-
kpis: SummaryKpis
|
|
226
|
-
history: HistoryPoint[]
|
|
227
|
-
slowest: RouteAggregate[]
|
|
228
|
-
mostErroring: RouteAggregate[]
|
|
229
|
-
recent: RequestLogSummary[]
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export interface MonitoringFilters {
|
|
233
|
-
period?: string
|
|
234
|
-
route?: string
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export type LogTab = 'requests' | 'errors' | 'slow'
|
|
238
|
-
|
|
239
|
-
export interface LogFilters {
|
|
240
|
-
tab?: LogTab
|
|
241
|
-
period?: string
|
|
242
|
-
method?: string
|
|
243
|
-
status?: string
|
|
244
|
-
search?: string
|
|
245
|
-
cursor?: string
|
|
246
|
-
limit?: number
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface LogPage {
|
|
250
|
-
results: RequestLogSummary[]
|
|
251
|
-
nextCursor: string | null
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Full single-log shape from /api/monitoring/logs/:id — same body as the
|
|
255
|
-
// LogDetailDrawer prop. Defined here so both Logs page and StatsView
|
|
256
|
-
// can fetch through the same facade.
|
|
257
|
-
export interface FullRequestLog extends RequestLogSummary {
|
|
258
|
-
pathParams?: Record<string, string>
|
|
259
|
-
query?: Record<string, string | string[]>
|
|
260
|
-
requestHeaders?: Record<string, string>
|
|
261
|
-
requestBody?: string
|
|
262
|
-
requestBodyTruncated?: boolean
|
|
263
|
-
responseHeaders?: Record<string, string>
|
|
264
|
-
responseBody?: string
|
|
265
|
-
responseBodyTruncated?: boolean
|
|
266
|
-
error?: { message: string; stack?: string }
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* How far back each store reaches, per the configured retentions. The day
|
|
271
|
-
* rollups behind the Overview and Routes charts and the raw logs behind the
|
|
272
|
-
* Logs page are pruned by two different settings.
|
|
273
|
-
*
|
|
274
|
-
* `requestLogRetentionDays` is optional: a backend older than the field simply
|
|
275
|
-
* omits it, and callers fall back to the statistics one.
|
|
276
|
-
*/
|
|
277
|
-
export interface StatsRetention {
|
|
278
|
-
statisticsLifetimeDays: number
|
|
279
|
-
requestLogRetentionDays?: number
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// --- Facade -----------------------------------------------------------------
|
|
283
|
-
|
|
284
|
-
export function useApiIntrospection() {
|
|
285
|
-
const { $authFetch } = useAuthFetch()
|
|
286
|
-
|
|
287
|
-
return {
|
|
288
|
-
// Tree
|
|
289
|
-
getTree: (period?: string) =>
|
|
290
|
-
$authFetch<ApiTreeNode[]>(
|
|
291
|
-
`/api/monitoring/routes/tree${period ? `?period=${encodeURIComponent(period)}` : ''}`,
|
|
292
|
-
),
|
|
293
|
-
|
|
294
|
-
// Per-route tabs
|
|
295
|
-
getRouteDoc: (id: string) =>
|
|
296
|
-
$authFetch<RouteDocPayload>(`/api/monitoring/routes/route/${id}/doc`),
|
|
297
|
-
getRouteConfig: (id: string) =>
|
|
298
|
-
$authFetch<RouteInspection>(`/api/monitoring/routes/route/${id}/config`),
|
|
299
|
-
getRouteStats: (id: string, period = '7d') =>
|
|
300
|
-
$authFetch<RouteStatsPayload>(
|
|
301
|
-
`/api/monitoring/routes/route/${id}/stats?period=${encodeURIComponent(period)}`,
|
|
302
|
-
),
|
|
303
|
-
|
|
304
|
-
// Retention backing the period selectors
|
|
305
|
-
getRetention: () =>
|
|
306
|
-
$authFetch<StatsRetention>('/api/monitoring/settings/retention'),
|
|
307
|
-
|
|
308
|
-
// Summary page
|
|
309
|
-
getSummary: () => $authFetch<SummaryPayload>('/api/monitoring/summary'),
|
|
310
|
-
getSummaryHistory: (period = '7d') =>
|
|
311
|
-
$authFetch<HistoryPoint[]>(
|
|
312
|
-
`/api/monitoring/summary/history?period=${encodeURIComponent(period)}`,
|
|
313
|
-
),
|
|
314
|
-
getStatusBreakdown: (period = '7d') =>
|
|
315
|
-
$authFetch<StatusBreakdown>(
|
|
316
|
-
`/api/monitoring/summary/status-breakdown?period=${encodeURIComponent(period)}`,
|
|
317
|
-
),
|
|
318
|
-
getWatchList: (limit = 4) =>
|
|
319
|
-
$authFetch<WatchListItem[]>(
|
|
320
|
-
`/api/monitoring/summary/watch-list?limit=${limit}`,
|
|
321
|
-
),
|
|
322
|
-
getActivity: () => $authFetch<ActivityItem[]>('/api/monitoring/summary/activity'),
|
|
323
|
-
|
|
324
|
-
// Monitoring page
|
|
325
|
-
getMonitoring: (filters: MonitoringFilters = {}) => {
|
|
326
|
-
const params = new URLSearchParams()
|
|
327
|
-
params.set('period', filters.period ?? '7d')
|
|
328
|
-
if (filters.route) params.set('route', filters.route)
|
|
329
|
-
return $authFetch<MonitoringPayload>(
|
|
330
|
-
`/api/monitoring/metrics?${params.toString()}`,
|
|
331
|
-
)
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
// Logs page
|
|
335
|
-
getLogs: (filters: LogFilters = {}) => {
|
|
336
|
-
const params = new URLSearchParams()
|
|
337
|
-
if (filters.tab) params.set('tab', filters.tab)
|
|
338
|
-
if (filters.period) params.set('period', filters.period)
|
|
339
|
-
if (filters.method) params.set('method', filters.method)
|
|
340
|
-
if (filters.status) params.set('status', filters.status)
|
|
341
|
-
if (filters.search) params.set('search', filters.search)
|
|
342
|
-
if (filters.cursor) params.set('cursor', filters.cursor)
|
|
343
|
-
if (filters.limit) params.set('limit', String(filters.limit))
|
|
344
|
-
const qs = params.toString()
|
|
345
|
-
return $authFetch<LogPage>(`/api/monitoring/logs${qs ? `?${qs}` : ''}`)
|
|
346
|
-
},
|
|
347
|
-
getLog: (id: string) =>
|
|
348
|
-
$authFetch<FullRequestLog>(`/api/monitoring/logs/${id}`),
|
|
349
|
-
}
|
|
350
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { onUnmounted, ref } from 'vue'
|
|
2
|
-
import LogDetailDrawer from '../components/LogDetailDrawer.vue'
|
|
3
|
-
import type { RequestLogSummary } from './useApiIntrospection'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Shared plumbing for every view that opens a request log in the right-hand
|
|
7
|
-
* drawer (Logs, Overview, route Statistics): loading state, fetch-then-open,
|
|
8
|
-
* and closing any drawer left open when the calling component unmounts — the
|
|
9
|
-
* drawer is a global overlay, so it would otherwise outlive navigation.
|
|
10
|
-
*/
|
|
11
|
-
export function useLogDetailDrawer() {
|
|
12
|
-
const { getLog } = useApiIntrospection()
|
|
13
|
-
const { open: openDrawer } = useDrawer()
|
|
14
|
-
|
|
15
|
-
const loadingDetailId = ref<string | null>(null)
|
|
16
|
-
const openDrawers: Array<{ result: Promise<unknown>; close: () => void }> =
|
|
17
|
-
[]
|
|
18
|
-
|
|
19
|
-
onUnmounted(() => {
|
|
20
|
-
for (const drawer of openDrawers.splice(0)) {
|
|
21
|
-
drawer.close()
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
async function openLogDetail(summary: RequestLogSummary) {
|
|
26
|
-
if (loadingDetailId.value === summary._id) return
|
|
27
|
-
loadingDetailId.value = summary._id
|
|
28
|
-
try {
|
|
29
|
-
const full = await getLog(summary._id)
|
|
30
|
-
const instance = openDrawer({
|
|
31
|
-
title: `${summary.method.toUpperCase()} ${summary.uri}`,
|
|
32
|
-
description: new Date(summary.timestamp).toLocaleString(),
|
|
33
|
-
component: LogDetailDrawer,
|
|
34
|
-
componentOptions: { log: full },
|
|
35
|
-
direction: 'right',
|
|
36
|
-
})
|
|
37
|
-
openDrawers.push(instance)
|
|
38
|
-
void instance.result.then(() => {
|
|
39
|
-
const idx = openDrawers.indexOf(instance)
|
|
40
|
-
if (idx >= 0) openDrawers.splice(idx, 1)
|
|
41
|
-
})
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error('[dms-api] failed to load log detail', e)
|
|
44
|
-
} finally {
|
|
45
|
-
loadingDetailId.value = null
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return { loadingDetailId, openLogDetail }
|
|
50
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { isPeriodOffered, type PeriodOption } from './useStatsPeriods'
|
|
2
|
-
|
|
3
|
-
const STORAGE_KEY = 'dms-api:period'
|
|
4
|
-
const STATE_KEY = 'dms-api-selected-period'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The period the user last picked, shared by the Overview, Routes and Logs
|
|
8
|
-
* pages and kept across navigation and reloads.
|
|
9
|
-
*
|
|
10
|
-
* One preference for the whole module, not one per page: picking `30d` on the
|
|
11
|
-
* Overview is a statement about what the user is looking at, and having each
|
|
12
|
-
* page remember its own would make the console disagree with itself.
|
|
13
|
-
*
|
|
14
|
-
* `useState` carries it across in-app navigation, `localStorage` across
|
|
15
|
-
* reloads. Reads and writes are guarded for SSR — there is no localStorage on
|
|
16
|
-
* the server, and the state has to hydrate to whatever the server rendered.
|
|
17
|
-
*/
|
|
18
|
-
export function useSelectedPeriod() {
|
|
19
|
-
const stored = useDmsState<string | null>(STATE_KEY, () => null)
|
|
20
|
-
|
|
21
|
-
function read(): string | null {
|
|
22
|
-
if (stored.value) return stored.value
|
|
23
|
-
if (typeof window === 'undefined') return null
|
|
24
|
-
try {
|
|
25
|
-
const value = window.localStorage.getItem(STORAGE_KEY)
|
|
26
|
-
stored.value = value
|
|
27
|
-
return value
|
|
28
|
-
} catch {
|
|
29
|
-
// Private mode / disabled storage: the in-memory state still works for
|
|
30
|
-
// the session, it just won't outlive the tab.
|
|
31
|
-
return null
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function set(value: string): void {
|
|
36
|
-
stored.value = value
|
|
37
|
-
if (typeof window === 'undefined') return
|
|
38
|
-
try {
|
|
39
|
-
window.localStorage.setItem(STORAGE_KEY, value)
|
|
40
|
-
} catch {
|
|
41
|
-
/* see read() */
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function resolve(
|
|
46
|
-
deepLink: string | undefined,
|
|
47
|
-
options: PeriodOption[],
|
|
48
|
-
fallback: string,
|
|
49
|
-
): string {
|
|
50
|
-
return resolvePeriod(deepLink, options, read(), fallback)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { resolve, set }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The window a page should open on.
|
|
58
|
-
*
|
|
59
|
-
* 1. A `?period=` deep link wins — the Overview cards link into Logs with the
|
|
60
|
-
* window the row belongs to, and that intent outranks the preference. It
|
|
61
|
-
* deliberately does not overwrite what is stored: following one link should
|
|
62
|
-
* not repoint the whole console.
|
|
63
|
-
* 2. Otherwise the stored preference, but only if this page offers it — a
|
|
64
|
-
* stored `1h` is valid on Logs and meaningless on Routes.
|
|
65
|
-
* 3. Otherwise the page's own default, already clamped to its retention.
|
|
66
|
-
*
|
|
67
|
-
* A window the page cannot offer is *widened to the widest one it has*, not
|
|
68
|
-
* dropped. The two retentions are configured separately, so a row seen at 90d
|
|
69
|
-
* on the Overview can link into a Logs page that only keeps 30d — landing on
|
|
70
|
-
* the 7-day default would show none of the traffic the row was about.
|
|
71
|
-
*/
|
|
72
|
-
export function resolvePeriod(
|
|
73
|
-
deepLink: string | undefined,
|
|
74
|
-
options: PeriodOption[],
|
|
75
|
-
stored: string | null,
|
|
76
|
-
fallback: string,
|
|
77
|
-
): string {
|
|
78
|
-
for (const candidate of [deepLink, stored]) {
|
|
79
|
-
if (isPeriodOffered(candidate, options)) return candidate as string
|
|
80
|
-
const widened = widestOfferedBelow(candidate, options)
|
|
81
|
-
if (widened) return widened
|
|
82
|
-
}
|
|
83
|
-
return fallback
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The widest window `options` offers that is no longer than `wanted`. Only
|
|
88
|
-
* day windows compare — `1h` is either offered verbatim or has no equivalent.
|
|
89
|
-
*/
|
|
90
|
-
function widestOfferedBelow(
|
|
91
|
-
wanted: string | undefined | null,
|
|
92
|
-
options: PeriodOption[],
|
|
93
|
-
): string | null {
|
|
94
|
-
const days = wanted?.match(/^(\d+)d$/)
|
|
95
|
-
if (!days) return null
|
|
96
|
-
const target = Number(days[1])
|
|
97
|
-
let best: { value: string; days: number } | null = null
|
|
98
|
-
for (const option of options) {
|
|
99
|
-
const m = option.value.match(/^(\d+)d$/)
|
|
100
|
-
if (!m) continue
|
|
101
|
-
const n = Number(m[1])
|
|
102
|
-
if (n <= target && (!best || n > best.days)) {
|
|
103
|
-
best = { value: option.value, days: n }
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return best?.value ?? null
|
|
107
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { computed, ref } from 'vue'
|
|
2
|
-
import type { StatsRetention } from './useApiIntrospection'
|
|
3
|
-
|
|
4
|
-
export interface PeriodOption {
|
|
5
|
-
value: string
|
|
6
|
-
label: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Which store the windows are read from, and therefore which retention bounds
|
|
11
|
-
* them: the Overview and Routes charts come from the day rollups, the Logs
|
|
12
|
-
* page from the raw request logs. The two are pruned by separate settings.
|
|
13
|
-
*/
|
|
14
|
-
export type PeriodKind = 'stats' | 'logs'
|
|
15
|
-
|
|
16
|
-
// Windows offered by every period filter, shortest first. Only the ones
|
|
17
|
-
// strictly shorter than the retention are kept: the retention itself is
|
|
18
|
-
// appended as the "all" entry, so the list always ends on the oldest day the
|
|
19
|
-
// data can still answer for and never offers a window that would chart empty.
|
|
20
|
-
const CANDIDATE_DAYS = [1, 7, 30, 90, 180]
|
|
21
|
-
|
|
22
|
-
// Sub-day window, offered on Logs only — the day rollups behind the other two
|
|
23
|
-
// pages cannot resolve it. Kept as the primary debugging window.
|
|
24
|
-
const HOUR_OPTION: PeriodOption = { value: '1h', label: '1h' }
|
|
25
|
-
|
|
26
|
-
const PREFERRED_DEFAULT_DAYS = 7
|
|
27
|
-
|
|
28
|
-
const RETENTION_STATE_KEY = 'dms-api-retention'
|
|
29
|
-
|
|
30
|
-
// What the module ships with (STATISTICS_RETENTION_MS). Used until the real
|
|
31
|
-
// retention is known, and when it can't be read at all — an older backend has
|
|
32
|
-
// no retention endpoint — so the selector degrades to the options it had
|
|
33
|
-
// before rather than emptying out.
|
|
34
|
-
const FALLBACK_MAX_DAYS = 30
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Period options for a monitoring page, derived from the retention configured
|
|
38
|
-
* on the Settings page. Raising it to a year makes a year's worth of windows
|
|
39
|
-
* selectable; lowering it to a few days shrinks the list to match.
|
|
40
|
-
*
|
|
41
|
-
* Values are the backend-native `Nd` / `Nh` tokens both parsers already read
|
|
42
|
-
* (`parsePeriod` in services/period.ts, `periodToMs` in routes/logs.ts), so the
|
|
43
|
-
* same string can be stored, deep-linked and sent as a query parameter without
|
|
44
|
-
* translation. Labels stay human.
|
|
45
|
-
*
|
|
46
|
-
* The retention is re-read on every `load()` rather than cached across the
|
|
47
|
-
* session: it changes whenever someone saves the Settings page, and a stale
|
|
48
|
-
* ceiling would silently cap the selector at the old value.
|
|
49
|
-
*/
|
|
50
|
-
export function useStatsPeriods(kind: PeriodKind = 'stats') {
|
|
51
|
-
const { getRetention } = useApiIntrospection()
|
|
52
|
-
const maxDays = ref(FALLBACK_MAX_DAYS)
|
|
53
|
-
// One request per navigation, not one per page: the retention is a single
|
|
54
|
-
// setting and every page asks for it on mount. Cleared on a full reload,
|
|
55
|
-
// which is also when a Settings change takes effect for the whole console.
|
|
56
|
-
const cached = useDmsState<StatsRetention | null>(RETENTION_STATE_KEY, () => null)
|
|
57
|
-
|
|
58
|
-
const options = computed<PeriodOption[]>(() =>
|
|
59
|
-
buildPeriodOptions(maxDays.value, kind),
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Read the retention, then report the window to start on: `7d` unless the
|
|
64
|
-
* retention is shorter than a week, in which case the whole retention is the
|
|
65
|
-
* widest thing there is to show.
|
|
66
|
-
*/
|
|
67
|
-
async function load(): Promise<string> {
|
|
68
|
-
if (!cached.value) {
|
|
69
|
-
try {
|
|
70
|
-
cached.value = await getRetention()
|
|
71
|
-
} catch {
|
|
72
|
-
// No retention endpoint (older backend) or a failed call: fall through
|
|
73
|
-
// with the shipped default rather than leaving the page without a
|
|
74
|
-
// window to fetch.
|
|
75
|
-
cached.value = null
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
maxDays.value = resolveMaxDays(cached.value, kind)
|
|
79
|
-
return defaultPeriodFor(maxDays.value)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return { options, load }
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Ceiling for a page's option list, from a retention payload.
|
|
87
|
-
*
|
|
88
|
-
* The log retention is the right one for the Logs page, but a backend that
|
|
89
|
-
* predates the field omits it — fall back to the statistics one rather than to
|
|
90
|
-
* the shipped default, which is usually further off.
|
|
91
|
-
*/
|
|
92
|
-
export function resolveMaxDays(
|
|
93
|
-
retention: StatsRetention | null | undefined,
|
|
94
|
-
kind: PeriodKind,
|
|
95
|
-
): number {
|
|
96
|
-
const raw =
|
|
97
|
-
kind === 'logs'
|
|
98
|
-
? (retention?.requestLogRetentionDays ??
|
|
99
|
-
retention?.statisticsLifetimeDays)
|
|
100
|
-
: retention?.statisticsLifetimeDays
|
|
101
|
-
const days = Math.round(raw as number)
|
|
102
|
-
// Number.isFinite, not Math.max: `Math.max(1, NaN)` is NaN, so a payload
|
|
103
|
-
// missing the field would poison every window built from it.
|
|
104
|
-
return Number.isFinite(days) && days >= 1 ? days : FALLBACK_MAX_DAYS
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Starting window: a week, or the whole retention when that is shorter. */
|
|
108
|
-
export function defaultPeriodFor(maxDays: number): string {
|
|
109
|
-
return `${Math.min(PREFERRED_DEFAULT_DAYS, maxDays)}d`
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function buildPeriodOptions(
|
|
113
|
-
maxDays: number,
|
|
114
|
-
kind: PeriodKind,
|
|
115
|
-
): PeriodOption[] {
|
|
116
|
-
const options = CANDIDATE_DAYS.filter((d) => d < maxDays).map((d) => ({
|
|
117
|
-
value: `${d}d`,
|
|
118
|
-
label: labelFor(d),
|
|
119
|
-
}))
|
|
120
|
-
options.push({ value: `${maxDays}d`, label: `${labelFor(maxDays)} (all)` })
|
|
121
|
-
// Logs also reads raw rows, so it can go below a day. There is no separate
|
|
122
|
-
// "all time" entry: rows past the retention are pruned, so the widest window
|
|
123
|
-
// and "everything" are the same data.
|
|
124
|
-
return kind === 'logs' ? [HOUR_OPTION, ...options] : options
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function labelFor(days: number): string {
|
|
128
|
-
if (days === 1) return '24h'
|
|
129
|
-
if (days % 365 === 0) return `${days / 365}y`
|
|
130
|
-
return `${days}d`
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Whether a stored/deep-linked value is offered by a page's option list. */
|
|
134
|
-
export function isPeriodOffered(
|
|
135
|
-
value: string | undefined | null,
|
|
136
|
-
options: PeriodOption[],
|
|
137
|
-
): boolean {
|
|
138
|
-
return !!value && options.some((o) => o.value === value)
|
|
139
|
-
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export type BadgeColor =
|
|
2
|
-
| 'success'
|
|
3
|
-
| 'primary'
|
|
4
|
-
| 'warning'
|
|
5
|
-
| 'error'
|
|
6
|
-
| 'info'
|
|
7
|
-
| 'neutral'
|
|
8
|
-
|
|
9
|
-
// Shared HTTP verb -> semantic badge color for every method pill in the API
|
|
10
|
-
// pages (method badge, tester, logs list, log detail). Mirrors the backend's
|
|
11
|
-
// HTTP_METHOD_ICONS map so icon and color stay in sync, and keeps the four
|
|
12
|
-
// call sites from each re-deriving the same mapping.
|
|
13
|
-
const HTTP_METHOD_COLORS: Record<string, BadgeColor> = {
|
|
14
|
-
GET: 'success',
|
|
15
|
-
POST: 'primary',
|
|
16
|
-
PUT: 'warning',
|
|
17
|
-
PATCH: 'warning',
|
|
18
|
-
DELETE: 'error',
|
|
19
|
-
OPTIONS: 'info',
|
|
20
|
-
HEAD: 'info',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function httpMethodColor(method: string): BadgeColor {
|
|
24
|
-
return HTTP_METHOD_COLORS[method.toUpperCase()] ?? 'neutral'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Verbs offered by the method filters (Logs toolbar, routes tree). */
|
|
28
|
-
export const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] as const
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* No-filter sentinel for the method/status/period selects. Not an empty string:
|
|
32
|
-
* Reka-ui's SelectItem rejects those (an empty value clears the selection in
|
|
33
|
-
* Nuxt UI), so the request builders strip this value instead.
|
|
34
|
-
*/
|
|
35
|
-
export const ANY_FILTER = 'any'
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Items for a method `<USelect>`, shared by the Logs toolbar and the routes
|
|
39
|
-
* tree so the two filters can't drift. Verbs stay untranslated — they are
|
|
40
|
-
* protocol tokens; only the "any" entry takes a label.
|
|
41
|
-
*/
|
|
42
|
-
export function httpMethodFilterItems(
|
|
43
|
-
anyLabel: string,
|
|
44
|
-
): Array<{ value: string; label: string }> {
|
|
45
|
-
return [
|
|
46
|
-
{ value: ANY_FILTER, label: anyLabel },
|
|
47
|
-
...HTTP_METHODS.map((method) => ({ value: method, label: method })),
|
|
48
|
-
]
|
|
49
|
-
}
|