@antelopejs/dms-api 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -5
- 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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onActivated, onBeforeUnmount, onMounted } from 'vue'
|
|
3
|
+
|
|
4
|
+
// "Own routes · 42": the route scope every page of the console is filtered
|
|
5
|
+
// by, linking to where it is changed. The backend fills it per request, and
|
|
6
|
+
// the chip reads it again as it mounts or comes back from the page cache
|
|
7
|
+
// (back from Settings, where the scope changes), when its tab is shown again
|
|
8
|
+
// (changed in another tab), and at most once a minute when the page's blocks
|
|
9
|
+
// refresh: a page restored from the history keeps the layout it was first
|
|
10
|
+
// served with. The scope rarely changes, so the chip does not follow the live
|
|
11
|
+
// feed. Present in the toolbar of every live page, it also tells the page's
|
|
12
|
+
// live toggle the server errors missed while paused (`useLiveMissedErrors`).
|
|
13
|
+
defineOptions({ inheritAttrs: false })
|
|
14
|
+
|
|
15
|
+
type Scope = 'own' | 'modules' | 'all'
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
scope?: Scope
|
|
19
|
+
routes?: number
|
|
20
|
+
to?: string
|
|
21
|
+
fetchUrl?: string
|
|
22
|
+
/** The live feed (`LIVE_REQUESTS_TOPIC`), whose missed 5xx it counts. */
|
|
23
|
+
realtimeTopic?: string
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const { t } = useI18n()
|
|
27
|
+
const { formatNumber } = useRegionalFormat({ locale: 'format' })
|
|
28
|
+
const summary = useApiResource<{ scope: Scope; routes: number }>(
|
|
29
|
+
() => props.fetchUrl,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const scope = computed(() => summary.data.value?.scope ?? props.scope ?? 'own')
|
|
33
|
+
const routes = computed(() => summary.data.value?.routes ?? props.routes ?? 0)
|
|
34
|
+
|
|
35
|
+
const label = computed(() =>
|
|
36
|
+
t(`api.scope.${scope.value}`, {
|
|
37
|
+
count: formatNumber(routes.value),
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A refresh of the page's blocks reads the scope again, once a minute at
|
|
43
|
+
* most: it changes on the Settings page, not with traffic.
|
|
44
|
+
*/
|
|
45
|
+
const REFRESH_INTERVAL_MS = 60_000
|
|
46
|
+
|
|
47
|
+
// When the chip last asked, so that a failing read is not retried each tick.
|
|
48
|
+
let lastAskedAt = Date.now()
|
|
49
|
+
|
|
50
|
+
function refreshIfStale() {
|
|
51
|
+
const last = Math.max(lastAskedAt, summary.receivedAt.value ?? 0)
|
|
52
|
+
if (Date.now() - last < REFRESH_INTERVAL_MS) return
|
|
53
|
+
lastAskedAt = Date.now()
|
|
54
|
+
void summary.refresh()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
usePageLiveRefresh(refreshIfStale)
|
|
58
|
+
if (props.realtimeTopic) useLiveMissedErrors(props.realtimeTopic)
|
|
59
|
+
|
|
60
|
+
function refreshWhenShown() {
|
|
61
|
+
if (document.visibilityState === 'visible') void summary.refresh()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// The first activation follows the mount, which already read the scope.
|
|
65
|
+
let activated = false
|
|
66
|
+
onActivated(() => {
|
|
67
|
+
if (activated) void summary.refresh()
|
|
68
|
+
activated = true
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
onMounted(() => document.addEventListener('visibilitychange', refreshWhenShown))
|
|
72
|
+
onBeforeUnmount(() =>
|
|
73
|
+
document.removeEventListener('visibilitychange', refreshWhenShown),
|
|
74
|
+
)
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<UTooltip :text="t('api.scope.tooltip')">
|
|
79
|
+
<UButton
|
|
80
|
+
:to="to"
|
|
81
|
+
:label="label"
|
|
82
|
+
icon="i-ph-funnel"
|
|
83
|
+
color="neutral"
|
|
84
|
+
variant="outline"
|
|
85
|
+
size="sm"
|
|
86
|
+
class="font-mono text-xs"
|
|
87
|
+
/>
|
|
88
|
+
</UTooltip>
|
|
89
|
+
</template>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
// A number of the Settings form (the request logs' retention, the body cap,
|
|
5
|
+
// the slow threshold), drawn by the DMS number input at the width of a
|
|
6
|
+
// number. The input keeps a typed value within its bounds and on its steps
|
|
7
|
+
// when it is left: 1020 typed for steps of 50 becomes 1,000. The field then
|
|
8
|
+
// shows the value it holds, never the one typed, and says why it changed
|
|
9
|
+
// (the input's `adjust`). The form brings it into view and focuses it from a
|
|
10
|
+
// link to its anchor (`…/settings#requestLogMaxBodyKb`).
|
|
11
|
+
defineOptions({ inheritAttrs: false })
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
id?: string
|
|
15
|
+
min?: number
|
|
16
|
+
max?: number
|
|
17
|
+
step?: number
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
}>()
|
|
20
|
+
const model = defineModel<number | null | undefined>()
|
|
21
|
+
|
|
22
|
+
const { t } = useI18n()
|
|
23
|
+
const { formatLocale, formatNumber } = useRegionalFormat({ locale: 'format' })
|
|
24
|
+
|
|
25
|
+
// How the input changed what was typed, until the value changes again.
|
|
26
|
+
const adjustment = ref<InputNumberAdjustment | null>(null)
|
|
27
|
+
|
|
28
|
+
watch(model, (value) => {
|
|
29
|
+
if (value !== adjustment.value?.value) adjustment.value = null
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const adjustmentText = computed(() => {
|
|
33
|
+
const current = adjustment.value
|
|
34
|
+
if (!current) return ''
|
|
35
|
+
return t(`api.settings.number.adjusted_${current.reason}`, {
|
|
36
|
+
typed: formatNumber(current.typed),
|
|
37
|
+
value: formatNumber(current.value),
|
|
38
|
+
step: formatNumber(props.step ?? 1),
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div class="grid gap-1.5">
|
|
45
|
+
<DmsInputNumber
|
|
46
|
+
:id="props.id"
|
|
47
|
+
v-model="model"
|
|
48
|
+
:min="props.min"
|
|
49
|
+
:max="props.max"
|
|
50
|
+
:step="props.step"
|
|
51
|
+
:locale="formatLocale"
|
|
52
|
+
:disabled="props.disabled"
|
|
53
|
+
class="w-40"
|
|
54
|
+
@adjust="adjustment = $event"
|
|
55
|
+
/>
|
|
56
|
+
<p
|
|
57
|
+
v-if="adjustmentText"
|
|
58
|
+
class="text-muted flex items-start gap-1.5 text-xs"
|
|
59
|
+
role="status"
|
|
60
|
+
>
|
|
61
|
+
<UIcon name="i-ph-info" class="mt-px size-3.5 shrink-0" />
|
|
62
|
+
<span>{{ adjustmentText }}</span>
|
|
63
|
+
</p>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
// A list beside the item it selects: the children placed in the `aside` slot
|
|
5
|
+
// keep a fixed column on wide screens, the others take the rest and stack
|
|
6
|
+
// under it on narrow ones (the layout's own width, not the screen's: the
|
|
7
|
+
// DMS sidebar or a docked panel leave less room). The aside sticks under the
|
|
8
|
+
// top of the screen; what it holds caps its own height to the screen (plain
|
|
9
|
+
// CSS, nothing measured). A DMS Grid shares its columns equally. The
|
|
10
|
+
// children of the `route` slot need a route that exists: they wait, hidden,
|
|
11
|
+
// while the URL names none or one the runtime does not register, and the
|
|
12
|
+
// header says why.
|
|
13
|
+
defineOptions({ inheritAttrs: false })
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(
|
|
16
|
+
defineProps<{ asideWidth?: string; detailUrl?: string; queryKey?: string }>(),
|
|
17
|
+
{ asideWidth: '340px', detailUrl: undefined, queryKey: 'route' },
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const detail = props.detailUrl
|
|
21
|
+
? useRouteDetail(props.detailUrl, props.queryKey)
|
|
22
|
+
: null
|
|
23
|
+
const routeReady = computed(
|
|
24
|
+
() => !!detail?.selection.ref.value && !detail.missing.value,
|
|
25
|
+
)
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="@container">
|
|
30
|
+
<div
|
|
31
|
+
class="grid grid-cols-1 items-start gap-4 @5xl:grid-cols-[var(--api-aside)_minmax(0,1fr)]"
|
|
32
|
+
:style="{ '--api-aside': asideWidth }"
|
|
33
|
+
>
|
|
34
|
+
<div class="min-w-0 @5xl:sticky @5xl:top-4"><slot name="aside" /></div>
|
|
35
|
+
<div class="flex min-w-0 flex-col gap-4">
|
|
36
|
+
<slot />
|
|
37
|
+
<slot v-if="routeReady" name="route" />
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { byteLength, formatBytes } from '../../utils/format'
|
|
4
|
+
import { bodyOmission } from '../../utils/requestDrawer'
|
|
5
|
+
import ApiJsonTree from './ApiJsonTree.vue'
|
|
6
|
+
|
|
7
|
+
// A captured body: a JSON one as a tree (or as text, on demand), anything
|
|
8
|
+
// else as text. Its label says how much was kept of how much was sent; no
|
|
9
|
+
// body says why none was stored.
|
|
10
|
+
const props = withDefaults(
|
|
11
|
+
defineProps<{
|
|
12
|
+
body?: string | null
|
|
13
|
+
truncated?: boolean
|
|
14
|
+
/** Why no body was stored, as the API names it. */
|
|
15
|
+
omitted?: string | null
|
|
16
|
+
/** The size the body had before it was cut, in bytes. */
|
|
17
|
+
originalSize?: number
|
|
18
|
+
/** The request's method: GET and HEAD send no body. */
|
|
19
|
+
method?: string
|
|
20
|
+
kind: 'request' | 'response'
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
body: undefined,
|
|
24
|
+
truncated: false,
|
|
25
|
+
omitted: undefined,
|
|
26
|
+
originalSize: undefined,
|
|
27
|
+
method: undefined,
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
/** Methods that send no body. */
|
|
32
|
+
const BODILESS_METHODS = ['GET', 'HEAD']
|
|
33
|
+
/** Where the body capture is set. */
|
|
34
|
+
const BODY_SETTINGS_LINK = '/modules/api/settings#requestLogMaxBodyKb'
|
|
35
|
+
|
|
36
|
+
const { t } = useI18n()
|
|
37
|
+
const { formatLocale: locale } = useRegionalFormat({ locale: 'format' })
|
|
38
|
+
|
|
39
|
+
const parsed = computed<{ value: unknown } | undefined>(() => {
|
|
40
|
+
if (!props.body) return undefined
|
|
41
|
+
try {
|
|
42
|
+
return { value: JSON.parse(props.body) }
|
|
43
|
+
} catch {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
const text = computed(() =>
|
|
48
|
+
parsed.value
|
|
49
|
+
? JSON.stringify(parsed.value.value, null, 2)
|
|
50
|
+
: (props.body ?? ''),
|
|
51
|
+
)
|
|
52
|
+
const raw = ref(false)
|
|
53
|
+
|
|
54
|
+
const label = computed(() => {
|
|
55
|
+
const kept = formatBytes(byteLength(props.body ?? ''), locale.value)
|
|
56
|
+
const size = props.originalSize
|
|
57
|
+
? t('api.request.body_size_of', {
|
|
58
|
+
kept,
|
|
59
|
+
total: formatBytes(props.originalSize, locale.value),
|
|
60
|
+
})
|
|
61
|
+
: kept
|
|
62
|
+
const cut = props.truncated ? ` · ${t('api.request.truncated')}` : ''
|
|
63
|
+
return `${parsed.value ? 'JSON' : 'TEXT'} · ${size}${cut}`
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const omission = computed(() => bodyOmission(props.omitted))
|
|
67
|
+
const bodiless = computed(
|
|
68
|
+
() =>
|
|
69
|
+
props.kind === 'request' &&
|
|
70
|
+
BODILESS_METHODS.includes((props.method ?? '').toUpperCase()),
|
|
71
|
+
)
|
|
72
|
+
const reason = computed(() => {
|
|
73
|
+
if (omission.value)
|
|
74
|
+
return t(`api.request.body_omitted.${omission.value.replace('-', '_')}`)
|
|
75
|
+
if (bodiless.value)
|
|
76
|
+
return t('api.request.no_body_method', {
|
|
77
|
+
method: (props.method ?? '').toUpperCase(),
|
|
78
|
+
})
|
|
79
|
+
return t('api.request.no_body')
|
|
80
|
+
})
|
|
81
|
+
// What the settings change: whether bodies are captured, and up to what size.
|
|
82
|
+
const toSettings = computed(
|
|
83
|
+
() =>
|
|
84
|
+
!bodiless.value &&
|
|
85
|
+
(omission.value === null ||
|
|
86
|
+
omission.value === 'disabled' ||
|
|
87
|
+
omission.value === 'too-large'),
|
|
88
|
+
)
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<div
|
|
93
|
+
v-if="body"
|
|
94
|
+
class="border-default bg-elevated/40 overflow-hidden rounded-md border"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
class="border-default text-dimmed flex items-center gap-2 border-b px-3 py-1 font-mono text-[10.5px] uppercase tracking-[0.08em]"
|
|
98
|
+
>
|
|
99
|
+
<span class="min-w-0 grow truncate">{{ label }}</span>
|
|
100
|
+
<UButton
|
|
101
|
+
v-if="parsed"
|
|
102
|
+
size="xs"
|
|
103
|
+
color="neutral"
|
|
104
|
+
variant="ghost"
|
|
105
|
+
:icon="raw ? 'i-ph-tree-view' : 'i-ph-text-align-left'"
|
|
106
|
+
:label="raw ? t('api.request.view_tree') : t('api.request.view_raw')"
|
|
107
|
+
@click="raw = !raw"
|
|
108
|
+
/>
|
|
109
|
+
<DmsCopyButton :value="text" />
|
|
110
|
+
</div>
|
|
111
|
+
<div v-if="parsed && !raw" class="max-h-[60vh] overflow-auto px-2 py-2">
|
|
112
|
+
<ApiJsonTree :value="parsed.value" />
|
|
113
|
+
</div>
|
|
114
|
+
<pre
|
|
115
|
+
v-else
|
|
116
|
+
class="text-default max-h-[60vh] overflow-auto whitespace-pre-wrap px-3 py-2.5 font-mono text-[12px] leading-relaxed [overflow-wrap:anywhere]"
|
|
117
|
+
><code>{{ text }}</code></pre>
|
|
118
|
+
</div>
|
|
119
|
+
<p v-else class="text-dimmed text-sm">
|
|
120
|
+
{{ reason }}
|
|
121
|
+
<ULink
|
|
122
|
+
v-if="toSettings"
|
|
123
|
+
:to="BODY_SETTINGS_LINK"
|
|
124
|
+
class="text-primary whitespace-nowrap hover:underline"
|
|
125
|
+
>
|
|
126
|
+
{{ t('api.request.body_settings') }}
|
|
127
|
+
</ULink>
|
|
128
|
+
</p>
|
|
129
|
+
</template>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
// A JSON value as a tree, as DevTools previews a payload: objects and arrays
|
|
5
|
+
// fold, the first levels open; a folded branch renders nothing below it, so
|
|
6
|
+
// a large body stays light.
|
|
7
|
+
const props = withDefaults(
|
|
8
|
+
defineProps<{
|
|
9
|
+
value: unknown
|
|
10
|
+
name?: string | number
|
|
11
|
+
depth?: number
|
|
12
|
+
}>(),
|
|
13
|
+
{ name: undefined, depth: 0 },
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
/** Levels open at first. */
|
|
17
|
+
const OPEN_DEPTH = 2
|
|
18
|
+
|
|
19
|
+
const { t } = useI18n()
|
|
20
|
+
|
|
21
|
+
const isBranch = computed(
|
|
22
|
+
() => props.value !== null && typeof props.value === 'object',
|
|
23
|
+
)
|
|
24
|
+
const isArray = computed(() => Array.isArray(props.value))
|
|
25
|
+
const entries = computed(() =>
|
|
26
|
+
isBranch.value ? Object.entries(props.value as object) : [],
|
|
27
|
+
)
|
|
28
|
+
const open = ref(props.depth < OPEN_DEPTH)
|
|
29
|
+
|
|
30
|
+
const summary = computed(() => {
|
|
31
|
+
const count = entries.value.length
|
|
32
|
+
return isArray.value
|
|
33
|
+
? `[ ${t('api.request.json_items', { count }, count)} ]`
|
|
34
|
+
: `{ ${t('api.request.json_keys', { count }, count)} }`
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const leaf = computed(() => JSON.stringify(props.value))
|
|
38
|
+
const leafTone = computed(() => {
|
|
39
|
+
if (props.value === null) return 'text-dimmed'
|
|
40
|
+
if (typeof props.value === 'string') return 'text-success'
|
|
41
|
+
if (typeof props.value === 'number') return 'text-info'
|
|
42
|
+
return 'text-warning'
|
|
43
|
+
})
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div class="font-mono text-[12px] leading-relaxed">
|
|
48
|
+
<template v-if="isBranch">
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
class="hover:bg-elevated inline-flex max-w-full items-center gap-1 rounded px-0.5 text-left"
|
|
52
|
+
:aria-expanded="open"
|
|
53
|
+
@click="open = !open"
|
|
54
|
+
>
|
|
55
|
+
<UIcon
|
|
56
|
+
:name="open ? 'i-ph-caret-down' : 'i-ph-caret-right'"
|
|
57
|
+
class="text-dimmed size-3 shrink-0"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
/>
|
|
60
|
+
<span v-if="name !== undefined" class="text-muted">
|
|
61
|
+
<bdi class="after:content-[':']">{{ name }}</bdi>
|
|
62
|
+
</span>
|
|
63
|
+
<span class="text-dimmed">{{ summary }}</span>
|
|
64
|
+
</button>
|
|
65
|
+
<div v-if="open" class="border-default ml-1.5 border-l pl-3">
|
|
66
|
+
<ApiJsonTree
|
|
67
|
+
v-for="[key, child] in entries"
|
|
68
|
+
:key="key"
|
|
69
|
+
:name="isArray ? Number(key) : key"
|
|
70
|
+
:value="child"
|
|
71
|
+
:depth="depth + 1"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
<div v-else class="flex gap-1 pl-4 [overflow-wrap:anywhere]">
|
|
76
|
+
<span v-if="name !== undefined" class="text-muted shrink-0">
|
|
77
|
+
<bdi class="after:content-[':']">{{ name }}</bdi>
|
|
78
|
+
</span>
|
|
79
|
+
<bdi :class="leafTone">{{ leaf }}</bdi>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
// Headers or parameters as a two-column list of names and values. A name
|
|
5
|
+
// stays on one line; a long value wraps between words where it can.
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
values: Record<string, unknown> | undefined | null
|
|
8
|
+
empty: string
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const entries = computed(() =>
|
|
12
|
+
Object.entries(props.values ?? {}).map(([name, value]) => [
|
|
13
|
+
name,
|
|
14
|
+
typeof value === 'string' ? value : JSON.stringify(value),
|
|
15
|
+
]),
|
|
16
|
+
)
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<p v-if="entries.length === 0" class="text-dimmed text-sm">{{ empty }}</p>
|
|
21
|
+
<table
|
|
22
|
+
v-else
|
|
23
|
+
class="border-default w-full border-separate border-spacing-0 overflow-hidden rounded-md border font-mono text-[12px]"
|
|
24
|
+
>
|
|
25
|
+
<tbody>
|
|
26
|
+
<tr v-for="[name, value] in entries" :key="name">
|
|
27
|
+
<th
|
|
28
|
+
scope="row"
|
|
29
|
+
class="text-muted border-default w-px whitespace-nowrap border-b px-3 py-1.5 text-left align-top font-normal"
|
|
30
|
+
>
|
|
31
|
+
<bdi>{{ name }}</bdi>
|
|
32
|
+
</th>
|
|
33
|
+
<td
|
|
34
|
+
class="text-default border-default border-b px-3 py-1.5 [overflow-wrap:anywhere]"
|
|
35
|
+
>
|
|
36
|
+
<bdi>{{ value }}</bdi>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
</template>
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import {
|
|
3
|
+
import { methodTone } from '../../utils/http'
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// per-verb semantic color. The verb → color mapping (the API-specific bit)
|
|
8
|
-
// lives in the shared `httpMethodColor` helper; the flat surface and its
|
|
9
|
-
// colors are inherited from the DMS theme.
|
|
5
|
+
// The method of a request or a route. Outline everywhere; `solid` only marks
|
|
6
|
+
// the request the tester is about to send.
|
|
10
7
|
const props = withDefaults(
|
|
11
8
|
defineProps<{
|
|
12
9
|
method: string
|
|
13
|
-
|
|
10
|
+
solid?: boolean
|
|
11
|
+
size?: 'sm' | 'md'
|
|
14
12
|
}>(),
|
|
15
|
-
{ size: '
|
|
13
|
+
{ solid: false, size: 'md' },
|
|
16
14
|
)
|
|
17
15
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const color = computed(() => httpMethodColor(upper.value))
|
|
16
|
+
const label = computed(() =>
|
|
17
|
+
props.method.toUpperCase() === 'DELETE' ? 'DEL' : props.method.toUpperCase(),
|
|
18
|
+
)
|
|
22
19
|
</script>
|
|
23
20
|
|
|
24
21
|
<template>
|
|
25
|
-
<
|
|
26
|
-
:
|
|
27
|
-
|
|
22
|
+
<DmsStatusPill
|
|
23
|
+
:tone="methodTone(method)"
|
|
24
|
+
:label="label"
|
|
25
|
+
:variant="solid ? 'soft' : 'outline'"
|
|
28
26
|
:size="size"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
dot="none"
|
|
28
|
+
mono
|
|
29
|
+
uppercase
|
|
30
|
+
class="min-w-[3.25rem] justify-center"
|
|
31
|
+
:title="method.toUpperCase()"
|
|
32
|
+
/>
|
|
33
33
|
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { pathSegments } from '../../utils/http'
|
|
4
|
+
|
|
5
|
+
// A route path in the mono font, `:params` highlighted. `prefix` dims the
|
|
6
|
+
// folder the path sits in, so the part that differs reads first.
|
|
7
|
+
const props = withDefaults(
|
|
8
|
+
defineProps<{
|
|
9
|
+
path: string
|
|
10
|
+
prefix?: string
|
|
11
|
+
}>(),
|
|
12
|
+
{ prefix: '' },
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const dimmed = computed(() =>
|
|
16
|
+
props.prefix &&
|
|
17
|
+
props.path.startsWith(props.prefix) &&
|
|
18
|
+
props.path !== props.prefix
|
|
19
|
+
? props.prefix
|
|
20
|
+
: '',
|
|
21
|
+
)
|
|
22
|
+
const rest = computed(() => pathSegments(props.path.slice(dimmed.value.length)))
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<span class="min-w-0 truncate font-mono" :title="path">
|
|
27
|
+
<span v-if="dimmed" class="text-dimmed">{{ dimmed }}</span>
|
|
28
|
+
<template v-for="(segment, index) in rest" :key="index">
|
|
29
|
+
<span v-if="segment.param" class="text-primary">{{ segment.text }}</span>
|
|
30
|
+
<template v-else>{{ segment.text }}</template>
|
|
31
|
+
</template>
|
|
32
|
+
</span>
|
|
33
|
+
</template>
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
+
import { statusText, statusTone } from '../../utils/http'
|
|
3
4
|
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// 4xx→warning, 5xx→error (0 / network error → error).
|
|
5
|
+
// A status code, tinted by its class (2xx, 3xx, 4xx, 5xx). With `text`, the
|
|
6
|
+
// reason phrase follows the code ("201 Created").
|
|
7
7
|
const props = withDefaults(
|
|
8
8
|
defineProps<{
|
|
9
|
-
status: number
|
|
10
|
-
|
|
9
|
+
status: number | string
|
|
10
|
+
text?: boolean
|
|
11
|
+
size?: 'sm' | 'md'
|
|
11
12
|
}>(),
|
|
12
|
-
{ size: '
|
|
13
|
+
{ text: false, size: 'md' },
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
16
|
+
const code = computed(() => Number(props.status))
|
|
17
|
+
const label = computed(() => {
|
|
18
|
+
if (!Number.isFinite(code.value) || code.value <= 0)
|
|
19
|
+
return String(props.status)
|
|
20
|
+
const phrase = props.text ? statusText(code.value) : ''
|
|
21
|
+
return phrase ? `${code.value} ${phrase}` : String(code.value)
|
|
21
22
|
})
|
|
22
23
|
</script>
|
|
23
24
|
|
|
24
25
|
<template>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
<DmsStatusPill
|
|
27
|
+
:tone="statusTone(status)"
|
|
28
|
+
:label="label"
|
|
29
|
+
:size="size"
|
|
30
|
+
dot="none"
|
|
31
|
+
mono
|
|
32
|
+
/>
|
|
28
33
|
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Marks a request the console's tester sent: it is kept in the logs, out of
|
|
3
|
+
// the statistics and the health.
|
|
4
|
+
const { t } = useI18n()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<UBadge
|
|
9
|
+
size="sm"
|
|
10
|
+
color="info"
|
|
11
|
+
variant="subtle"
|
|
12
|
+
icon="i-ph-paper-plane-tilt"
|
|
13
|
+
:label="t('api.request.tester')"
|
|
14
|
+
:title="t('api.request.source_tester')"
|
|
15
|
+
class="shrink-0"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed, toValue, type MaybeRefOrGetter } from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the API answers, for the snippets the console hands out (cURL,
|
|
5
|
+
* fetch). The backend reads it from the DMS (`GetApiBaseUrl()`, its
|
|
6
|
+
* `apiBaseUrl`) and sends it as the `apiOrigin` of the payloads that need it
|
|
7
|
+
* (a route's detail, a captured request). Never this page's own origin:
|
|
8
|
+
* behind the DMS frontend that is the frontend, whose proxy refuses the
|
|
9
|
+
* writes a copied command sends.
|
|
10
|
+
* Null while unknown: the snippets then write `$API_URL` and say so.
|
|
11
|
+
*/
|
|
12
|
+
export function useApiOrigin(
|
|
13
|
+
reported: MaybeRefOrGetter<string | null | undefined>,
|
|
14
|
+
) {
|
|
15
|
+
return computed(() => {
|
|
16
|
+
const origin = toValue(reported)?.trim()
|
|
17
|
+
return origin ? origin.replace(/\/+$/, '') : null
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed, onMounted, ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** Id of the console pages' `PeriodSelector` (`PERIOD_SCOPE`, server side). */
|
|
4
|
+
const PERIOD_SCOPE = 'api'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The period of the page as its DMS `PeriodSelector` resolves it: from the
|
|
8
|
+
* URL, else the user's last choice, else its default. `null` until the
|
|
9
|
+
* block is mounted: the period registry is client-only, and the server
|
|
10
|
+
* render and the hydration have to agree.
|
|
11
|
+
*/
|
|
12
|
+
export function useApiPeriod() {
|
|
13
|
+
const scope = usePeriodScope(PERIOD_SCOPE)
|
|
14
|
+
const mounted = ref(false)
|
|
15
|
+
onMounted(() => {
|
|
16
|
+
mounted.value = true
|
|
17
|
+
})
|
|
18
|
+
return computed(() => (mounted.value ? scope.value : null))
|
|
19
|
+
}
|