@antelopejs/dms-api 0.1.7 → 0.3.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/package.json +9 -9
- 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,499 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
3
|
-
import type {
|
|
4
|
-
ParameterInfo,
|
|
5
|
-
RouteInspection,
|
|
6
|
-
} from '../composables/useApiIntrospection'
|
|
7
|
-
import { httpMethodColor } from '../utils/httpMethod'
|
|
8
|
-
import { sendTesterRequest, type TesterRequest } from '../utils/testerRequest'
|
|
9
|
-
|
|
10
|
-
interface HeaderRow {
|
|
11
|
-
name: string
|
|
12
|
-
value: string
|
|
13
|
-
id: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface PathParamRow {
|
|
17
|
-
name: string
|
|
18
|
-
value: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface HistoryEntry {
|
|
22
|
-
id: string
|
|
23
|
-
timestamp: number
|
|
24
|
-
method: string
|
|
25
|
-
url: string
|
|
26
|
-
headers: Record<string, string>
|
|
27
|
-
body?: string
|
|
28
|
-
pathParams?: Record<string, string>
|
|
29
|
-
useSession?: boolean
|
|
30
|
-
status?: number
|
|
31
|
-
durationMs?: number
|
|
32
|
-
responseSnippet?: string
|
|
33
|
-
ok: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const props = defineProps<{
|
|
37
|
-
route: RouteInspection
|
|
38
|
-
}>()
|
|
39
|
-
|
|
40
|
-
const HISTORY_MAX = 25
|
|
41
|
-
const HISTORY_PREVIEW_BYTES = 200
|
|
42
|
-
const SUCCESS_STATUS_MIN = 200
|
|
43
|
-
const SUCCESS_STATUS_MAX = 300
|
|
44
|
-
|
|
45
|
-
const config = useDmsRuntimeConfig()
|
|
46
|
-
const { loggedIn } = useUserSession()
|
|
47
|
-
|
|
48
|
-
const baseURL = computed(() => {
|
|
49
|
-
const dmsApi = (config.public as Record<string, unknown>).dmsApi as
|
|
50
|
-
| { baseURL?: string }
|
|
51
|
-
| undefined
|
|
52
|
-
return dmsApi?.baseURL ?? ''
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const useSessionAuth = ref(true)
|
|
56
|
-
const canUseSession = computed(() => loggedIn.value)
|
|
57
|
-
|
|
58
|
-
const pathParams = reactive<PathParamRow[]>([])
|
|
59
|
-
const headers = reactive<HeaderRow[]>([])
|
|
60
|
-
const requestBody = ref('')
|
|
61
|
-
const sending = ref(false)
|
|
62
|
-
const response = ref<{
|
|
63
|
-
status: number
|
|
64
|
-
durationMs: number
|
|
65
|
-
headers: Record<string, string>
|
|
66
|
-
body: string
|
|
67
|
-
bodyIsJson: boolean
|
|
68
|
-
error?: string
|
|
69
|
-
} | null>(null)
|
|
70
|
-
const history = ref<HistoryEntry[]>([])
|
|
71
|
-
|
|
72
|
-
const methodHasBody = computed(() =>
|
|
73
|
-
/^(?:post|put|patch|delete)$/i.test(props.route.method),
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
const renderedUrl = computed(() => {
|
|
77
|
-
let url = props.route.location
|
|
78
|
-
for (const { name, value } of pathParams) {
|
|
79
|
-
if (!name) continue
|
|
80
|
-
url = url.replace(`:${name}`, encodeURIComponent(value || `:${name}`))
|
|
81
|
-
}
|
|
82
|
-
return url.startsWith('/') ? url : `/${url}`
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const fullUrl = computed(() => `${baseURL.value}${renderedUrl.value}`)
|
|
86
|
-
|
|
87
|
-
const methodBadgeColor = computed(() => httpMethodColor(props.route.method))
|
|
88
|
-
|
|
89
|
-
function historyKey(routeId: string): string {
|
|
90
|
-
return `dmsApi.tester.history.${routeId}`
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function loadHistory() {
|
|
94
|
-
if (typeof window === 'undefined') return
|
|
95
|
-
try {
|
|
96
|
-
const raw = window.localStorage.getItem(historyKey(props.route.id))
|
|
97
|
-
history.value = raw ? (JSON.parse(raw) as HistoryEntry[]) : []
|
|
98
|
-
} catch {
|
|
99
|
-
history.value = []
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function saveHistory() {
|
|
104
|
-
if (typeof window === 'undefined') return
|
|
105
|
-
try {
|
|
106
|
-
window.localStorage.setItem(
|
|
107
|
-
historyKey(props.route.id),
|
|
108
|
-
JSON.stringify(history.value.slice(0, HISTORY_MAX)),
|
|
109
|
-
)
|
|
110
|
-
} catch {
|
|
111
|
-
/* quota or disabled storage — ignore */
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function pathParamsFromLocation(location: string): string[] {
|
|
116
|
-
const out: string[] = []
|
|
117
|
-
for (const seg of location.split('/')) {
|
|
118
|
-
if (seg.startsWith(':')) out.push(seg.slice(1))
|
|
119
|
-
else if (seg.startsWith('::')) out.push(seg.slice(2))
|
|
120
|
-
}
|
|
121
|
-
return out
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function nameOf(p: ParameterInfo): string {
|
|
125
|
-
return p.name ?? `param_${p.index}`
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function cryptoId(): string {
|
|
129
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function resetFromRoute() {
|
|
133
|
-
pathParams.length = 0
|
|
134
|
-
for (const name of pathParamsFromLocation(props.route.location)) {
|
|
135
|
-
pathParams.push({ name, value: '' })
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
headers.length = 0
|
|
139
|
-
if (methodHasBody.value) {
|
|
140
|
-
headers.push({
|
|
141
|
-
name: 'Content-Type',
|
|
142
|
-
value: 'application/json',
|
|
143
|
-
id: cryptoId(),
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const bodyParam = props.route.parameters.find((p) => p.source === 'body')
|
|
148
|
-
if (methodHasBody.value && bodyParam) {
|
|
149
|
-
requestBody.value = '{\n \n}'
|
|
150
|
-
} else {
|
|
151
|
-
requestBody.value = ''
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
for (const p of props.route.parameters) {
|
|
155
|
-
if (p.source === 'header') {
|
|
156
|
-
headers.push({ name: nameOf(p), value: '', id: cryptoId() })
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
response.value = null
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function addHeader() {
|
|
164
|
-
headers.push({ name: '', value: '', id: cryptoId() })
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function removeHeader(id: string) {
|
|
168
|
-
const idx = headers.findIndex((h) => h.id === id)
|
|
169
|
-
if (idx >= 0) headers.splice(idx, 1)
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function buildHeaderRecord(): Record<string, string> {
|
|
173
|
-
const out: Record<string, string> = {}
|
|
174
|
-
for (const h of headers) {
|
|
175
|
-
if (!h.name) continue
|
|
176
|
-
out[h.name] = h.value
|
|
177
|
-
}
|
|
178
|
-
return out
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function buildPathParamRecord(): Record<string, string> {
|
|
182
|
-
return Object.fromEntries(pathParams.map(({ name, value }) => [name, value]))
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function handleTesterResponse(
|
|
186
|
-
result: Awaited<ReturnType<typeof sendTesterRequest>>,
|
|
187
|
-
request: TesterRequest,
|
|
188
|
-
url: string,
|
|
189
|
-
started: number,
|
|
190
|
-
) {
|
|
191
|
-
const durationMs = Math.round(performance.now() - started)
|
|
192
|
-
const isJson = /json/i.test(result.headers['content-type'] ?? '')
|
|
193
|
-
response.value = {
|
|
194
|
-
status: result.status,
|
|
195
|
-
durationMs,
|
|
196
|
-
headers: result.headers,
|
|
197
|
-
body: isJson ? safePretty(result.body) : result.body,
|
|
198
|
-
bodyIsJson: isJson,
|
|
199
|
-
}
|
|
200
|
-
pushHistory({
|
|
201
|
-
id: cryptoId(),
|
|
202
|
-
timestamp: Date.now(),
|
|
203
|
-
method: request.method,
|
|
204
|
-
url,
|
|
205
|
-
headers: request.headers,
|
|
206
|
-
body: methodHasBody.value ? requestBody.value : undefined,
|
|
207
|
-
pathParams: buildPathParamRecord(),
|
|
208
|
-
useSession: request.useSession,
|
|
209
|
-
status: result.status,
|
|
210
|
-
durationMs,
|
|
211
|
-
responseSnippet: result.body.slice(0, HISTORY_PREVIEW_BYTES),
|
|
212
|
-
ok:
|
|
213
|
-
result.status >= SUCCESS_STATUS_MIN && result.status < SUCCESS_STATUS_MAX,
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function handleTesterError(
|
|
218
|
-
error: unknown,
|
|
219
|
-
request: TesterRequest,
|
|
220
|
-
url: string,
|
|
221
|
-
started: number,
|
|
222
|
-
) {
|
|
223
|
-
const durationMs = Math.round(performance.now() - started)
|
|
224
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
225
|
-
response.value = {
|
|
226
|
-
status: 0,
|
|
227
|
-
durationMs,
|
|
228
|
-
headers: {},
|
|
229
|
-
body: message,
|
|
230
|
-
bodyIsJson: false,
|
|
231
|
-
error: message,
|
|
232
|
-
}
|
|
233
|
-
pushHistory({
|
|
234
|
-
id: cryptoId(),
|
|
235
|
-
timestamp: Date.now(),
|
|
236
|
-
method: request.method,
|
|
237
|
-
url,
|
|
238
|
-
headers: request.headers,
|
|
239
|
-
body: methodHasBody.value ? requestBody.value : undefined,
|
|
240
|
-
pathParams: buildPathParamRecord(),
|
|
241
|
-
useSession: request.useSession,
|
|
242
|
-
durationMs,
|
|
243
|
-
responseSnippet: message,
|
|
244
|
-
ok: false,
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function send() {
|
|
249
|
-
if (sending.value) return
|
|
250
|
-
sending.value = true
|
|
251
|
-
response.value = null
|
|
252
|
-
const url = fullUrl.value
|
|
253
|
-
const request: TesterRequest = {
|
|
254
|
-
method: props.route.method.toUpperCase(),
|
|
255
|
-
headers: buildHeaderRecord(),
|
|
256
|
-
useSession: useSessionAuth.value && canUseSession.value,
|
|
257
|
-
}
|
|
258
|
-
if (methodHasBody.value && requestBody.value.trim().length > 0) {
|
|
259
|
-
request.body = requestBody.value
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const started = performance.now()
|
|
263
|
-
try {
|
|
264
|
-
const result = await sendTesterRequest(url, window.location.origin, request)
|
|
265
|
-
handleTesterResponse(result, request, url, started)
|
|
266
|
-
} catch (error) {
|
|
267
|
-
handleTesterError(error, request, url, started)
|
|
268
|
-
} finally {
|
|
269
|
-
sending.value = false
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function pushHistory(entry: HistoryEntry) {
|
|
274
|
-
history.value.unshift(entry)
|
|
275
|
-
if (history.value.length > HISTORY_MAX) history.value.length = HISTORY_MAX
|
|
276
|
-
saveHistory()
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function recall(entry: HistoryEntry) {
|
|
280
|
-
headers.length = 0
|
|
281
|
-
for (const [name, value] of Object.entries(entry.headers)) {
|
|
282
|
-
headers.push({ name, value, id: cryptoId() })
|
|
283
|
-
}
|
|
284
|
-
for (const pathParam of pathParams) {
|
|
285
|
-
pathParam.value = entry.pathParams?.[pathParam.name] ?? pathParam.value
|
|
286
|
-
}
|
|
287
|
-
if (entry.body !== undefined) requestBody.value = entry.body
|
|
288
|
-
if (entry.useSession !== undefined) useSessionAuth.value = entry.useSession
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function clearHistory() {
|
|
292
|
-
history.value = []
|
|
293
|
-
saveHistory()
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function safePretty(text: string): string {
|
|
297
|
-
try {
|
|
298
|
-
return JSON.stringify(JSON.parse(text), null, 2)
|
|
299
|
-
} catch {
|
|
300
|
-
return text
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function statusColor(s?: number): string {
|
|
305
|
-
if (!s || s === 0) return 'error'
|
|
306
|
-
if (s >= 500) return 'error'
|
|
307
|
-
if (s >= 400) return 'warning'
|
|
308
|
-
if (s >= 300) return 'info'
|
|
309
|
-
return 'success'
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
watch(
|
|
313
|
-
() => props.route.id,
|
|
314
|
-
() => {
|
|
315
|
-
resetFromRoute()
|
|
316
|
-
loadHistory()
|
|
317
|
-
},
|
|
318
|
-
{ immediate: true },
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
onMounted(loadHistory)
|
|
322
|
-
</script>
|
|
323
|
-
|
|
324
|
-
<template>
|
|
325
|
-
<div class="flex w-full flex-col gap-4">
|
|
326
|
-
<!-- URL preview + send -->
|
|
327
|
-
<div class="flex flex-wrap items-center gap-2">
|
|
328
|
-
<UBadge :color="methodBadgeColor" variant="solid">
|
|
329
|
-
{{ route.method.toUpperCase() }}
|
|
330
|
-
</UBadge>
|
|
331
|
-
<code
|
|
332
|
-
class="bg-elevated text-highlighted grow rounded px-3 py-2 font-mono text-sm"
|
|
333
|
-
>
|
|
334
|
-
{{ fullUrl }}
|
|
335
|
-
</code>
|
|
336
|
-
<UButton
|
|
337
|
-
:loading="sending"
|
|
338
|
-
:disabled="sending"
|
|
339
|
-
color="primary"
|
|
340
|
-
icon="i-ph-paper-plane-tilt"
|
|
341
|
-
@click="send"
|
|
342
|
-
>
|
|
343
|
-
{{ $t('page.api.routes.tester.send') }}
|
|
344
|
-
</UButton>
|
|
345
|
-
</div>
|
|
346
|
-
|
|
347
|
-
<!-- Auth toggle -->
|
|
348
|
-
<label
|
|
349
|
-
class="text-muted flex items-center gap-2 self-start text-xs"
|
|
350
|
-
:class="{ 'opacity-60': !canUseSession }"
|
|
351
|
-
>
|
|
352
|
-
<USwitch v-model="useSessionAuth" :disabled="!canUseSession" size="xs" />
|
|
353
|
-
<span class="flex items-center gap-1">
|
|
354
|
-
<UIcon name="i-ph-shield-check" />
|
|
355
|
-
{{ $t('page.api.routes.tester.use_current_user') }}
|
|
356
|
-
</span>
|
|
357
|
-
<span class="text-dimmed">
|
|
358
|
-
{{
|
|
359
|
-
canUseSession
|
|
360
|
-
? $t('page.api.routes.tester.use_current_user_description')
|
|
361
|
-
: $t('page.api.routes.tester.auth_unavailable')
|
|
362
|
-
}}
|
|
363
|
-
</span>
|
|
364
|
-
</label>
|
|
365
|
-
|
|
366
|
-
<!-- Path params -->
|
|
367
|
-
<section v-if="pathParams.length > 0" class="flex flex-col gap-2">
|
|
368
|
-
<h4 class="text-highlighted text-sm font-semibold">
|
|
369
|
-
{{ $t('page.api.routes.tester.path_params') }}
|
|
370
|
-
</h4>
|
|
371
|
-
<div
|
|
372
|
-
v-for="(p, idx) in pathParams"
|
|
373
|
-
:key="p.name + idx"
|
|
374
|
-
class="grid grid-cols-[160px_1fr] gap-3"
|
|
375
|
-
>
|
|
376
|
-
<code class="text-muted self-center font-mono text-xs">
|
|
377
|
-
:{{ p.name }}
|
|
378
|
-
</code>
|
|
379
|
-
<UInput v-model="p.value" :placeholder="p.name" />
|
|
380
|
-
</div>
|
|
381
|
-
</section>
|
|
382
|
-
|
|
383
|
-
<!-- Headers -->
|
|
384
|
-
<section class="flex flex-col gap-2">
|
|
385
|
-
<div class="flex items-center justify-between">
|
|
386
|
-
<h4 class="text-highlighted text-sm font-semibold">
|
|
387
|
-
{{ $t('page.api.routes.tester.headers') }}
|
|
388
|
-
</h4>
|
|
389
|
-
<UButton size="xs" variant="ghost" icon="i-ph-plus" @click="addHeader">
|
|
390
|
-
{{ $t('page.api.routes.tester.add_header') }}
|
|
391
|
-
</UButton>
|
|
392
|
-
</div>
|
|
393
|
-
<div
|
|
394
|
-
v-for="h in headers"
|
|
395
|
-
:key="h.id"
|
|
396
|
-
class="grid grid-cols-[1fr_2fr_auto] gap-2"
|
|
397
|
-
>
|
|
398
|
-
<UInput
|
|
399
|
-
v-model="h.name"
|
|
400
|
-
:placeholder="$t('page.api.routes.tester.header_name')"
|
|
401
|
-
/>
|
|
402
|
-
<UInput
|
|
403
|
-
v-model="h.value"
|
|
404
|
-
:placeholder="$t('page.api.routes.tester.header_value')"
|
|
405
|
-
/>
|
|
406
|
-
<UButton
|
|
407
|
-
size="xs"
|
|
408
|
-
variant="ghost"
|
|
409
|
-
color="neutral"
|
|
410
|
-
icon="i-ph-x"
|
|
411
|
-
@click="removeHeader(h.id)"
|
|
412
|
-
/>
|
|
413
|
-
</div>
|
|
414
|
-
<p v-if="headers.length === 0" class="text-dimmed text-xs">
|
|
415
|
-
{{ $t('page.api.routes.tester.no_headers') }}
|
|
416
|
-
</p>
|
|
417
|
-
</section>
|
|
418
|
-
|
|
419
|
-
<!-- Body -->
|
|
420
|
-
<section v-if="methodHasBody" class="flex flex-col gap-2">
|
|
421
|
-
<h4 class="text-highlighted text-sm font-semibold">
|
|
422
|
-
{{ $t('page.api.routes.tester.body') }}
|
|
423
|
-
</h4>
|
|
424
|
-
<UTextarea v-model="requestBody" :rows="8" class="font-mono text-xs" />
|
|
425
|
-
</section>
|
|
426
|
-
|
|
427
|
-
<!-- Response panel -->
|
|
428
|
-
<section v-if="response" class="flex flex-col gap-2">
|
|
429
|
-
<div class="flex items-center gap-2">
|
|
430
|
-
<h4 class="text-highlighted text-sm font-semibold">
|
|
431
|
-
{{ $t('page.api.routes.tester.response') }}
|
|
432
|
-
</h4>
|
|
433
|
-
<UBadge :color="statusColor(response.status)" variant="subtle">
|
|
434
|
-
{{ response.status || $t('page.api.routes.tester.network_error') }}
|
|
435
|
-
</UBadge>
|
|
436
|
-
<span class="text-dimmed text-xs">{{ response.durationMs }} ms</span>
|
|
437
|
-
</div>
|
|
438
|
-
|
|
439
|
-
<div
|
|
440
|
-
v-if="Object.keys(response.headers).length > 0"
|
|
441
|
-
class="flex flex-col gap-1"
|
|
442
|
-
>
|
|
443
|
-
<p class="text-dimmed text-xs uppercase">
|
|
444
|
-
{{ $t('page.api.routes.tester.response_headers') }}
|
|
445
|
-
</p>
|
|
446
|
-
<dl class="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-xs">
|
|
447
|
-
<template v-for="(value, name) in response.headers" :key="name">
|
|
448
|
-
<dt class="text-muted font-mono">{{ name }}</dt>
|
|
449
|
-
<dd class="break-all font-mono">{{ value }}</dd>
|
|
450
|
-
</template>
|
|
451
|
-
</dl>
|
|
452
|
-
</div>
|
|
453
|
-
|
|
454
|
-
<div class="flex flex-col gap-1">
|
|
455
|
-
<p class="text-dimmed text-xs uppercase">
|
|
456
|
-
{{ $t('page.api.routes.tester.response_body') }}
|
|
457
|
-
</p>
|
|
458
|
-
<pre class="bg-elevated max-h-96 overflow-auto rounded p-3 text-xs">{{
|
|
459
|
-
response.body
|
|
460
|
-
}}</pre>
|
|
461
|
-
</div>
|
|
462
|
-
</section>
|
|
463
|
-
|
|
464
|
-
<!-- History -->
|
|
465
|
-
<section v-if="history.length > 0" class="flex flex-col gap-2">
|
|
466
|
-
<div class="flex items-center justify-between">
|
|
467
|
-
<h4 class="text-highlighted text-sm font-semibold">
|
|
468
|
-
{{ $t('page.api.routes.tester.history') }}
|
|
469
|
-
</h4>
|
|
470
|
-
<UButton
|
|
471
|
-
size="xs"
|
|
472
|
-
variant="ghost"
|
|
473
|
-
color="neutral"
|
|
474
|
-
icon="i-ph-trash"
|
|
475
|
-
@click="clearHistory"
|
|
476
|
-
>
|
|
477
|
-
{{ $t('page.api.routes.tester.clear_history') }}
|
|
478
|
-
</UButton>
|
|
479
|
-
</div>
|
|
480
|
-
<ul class="space-y-1">
|
|
481
|
-
<li
|
|
482
|
-
v-for="entry in history"
|
|
483
|
-
:key="entry.id"
|
|
484
|
-
class="border-default bg-elevated/40 hover:bg-elevated flex cursor-pointer items-center gap-3 rounded border px-3 py-2"
|
|
485
|
-
@click="recall(entry)"
|
|
486
|
-
>
|
|
487
|
-
<UBadge :color="statusColor(entry.status)" variant="subtle" size="xs">
|
|
488
|
-
{{ entry.status || 'ERR' }}
|
|
489
|
-
</UBadge>
|
|
490
|
-
<span class="text-dimmed text-xs">{{ entry.durationMs }} ms</span>
|
|
491
|
-
<span class="grow truncate font-mono text-xs">{{ entry.url }}</span>
|
|
492
|
-
<span class="text-dimmed text-xs">
|
|
493
|
-
{{ new Date(entry.timestamp).toLocaleTimeString() }}
|
|
494
|
-
</span>
|
|
495
|
-
</li>
|
|
496
|
-
</ul>
|
|
497
|
-
</section>
|
|
498
|
-
</div>
|
|
499
|
-
</template>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onMounted, ref } from 'vue'
|
|
3
|
-
import type { PeriodKind } from '../../composables/useStatsPeriods'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The period filter shared by the Overview, Routes and Logs pages.
|
|
7
|
-
*
|
|
8
|
-
* Owning the whole cycle here — read the retention, build the options, resolve
|
|
9
|
-
* the starting window, persist every change — is what keeps the three pages
|
|
10
|
-
* identical. They only see the resolved `Nd`/`Nh` value.
|
|
11
|
-
*
|
|
12
|
-
* `null` until the retention answers: pages hold off fetching rather than
|
|
13
|
-
* request a window nobody picked, which would otherwise be a wasted round-trip
|
|
14
|
-
* (or one past the retention) followed by a second for the real value.
|
|
15
|
-
*/
|
|
16
|
-
const props = withDefaults(
|
|
17
|
-
defineProps<{
|
|
18
|
-
/** Which retention bounds the list. */
|
|
19
|
-
kind?: PeriodKind
|
|
20
|
-
/** `?period=` deep link, when the page accepts one. */
|
|
21
|
-
deepLink?: string
|
|
22
|
-
size?: 'xs' | 'sm' | 'md'
|
|
23
|
-
class?: string
|
|
24
|
-
}>(),
|
|
25
|
-
{ kind: 'stats', size: 'sm', deepLink: undefined, class: undefined },
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const model = defineModel<string | null>({ required: true })
|
|
29
|
-
|
|
30
|
-
const { options, load } = useStatsPeriods(props.kind)
|
|
31
|
-
const { resolve, set } = useSelectedPeriod()
|
|
32
|
-
|
|
33
|
-
const ready = ref(false)
|
|
34
|
-
|
|
35
|
-
onMounted(async () => {
|
|
36
|
-
const fallback = await load()
|
|
37
|
-
model.value = resolve(props.deepLink, options.value, fallback)
|
|
38
|
-
ready.value = true
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
function onChange(value: string) {
|
|
42
|
-
model.value = value
|
|
43
|
-
set(value)
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<template>
|
|
48
|
-
<USelect
|
|
49
|
-
v-if="ready"
|
|
50
|
-
:model-value="model ?? undefined"
|
|
51
|
-
:items="options"
|
|
52
|
-
:size="size"
|
|
53
|
-
:class="props.class"
|
|
54
|
-
:aria-label="$t('page.api.filters.period')"
|
|
55
|
-
@update:model-value="onChange"
|
|
56
|
-
/>
|
|
57
|
-
<USkeleton v-else class="h-8 w-28" :class="props.class" />
|
|
58
|
-
</template>
|