@antelopejs/dms-api 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -148
- package/dist/db/models/api_settings.model.d.ts +1 -0
- package/dist/db/models/request_log.model.d.ts +1 -0
- package/dist/db/models/routes.model.d.ts +1 -0
- package/dist/db/models/routes_statistics.model.d.ts +1 -0
- package/frontend-vue/app/components/blocks/HealthHero.vue +11 -5
- package/frontend-vue/app/components/blocks/LiveTraffic.vue +3 -2
- package/frontend-vue/app/components/blocks/RequestDetail.vue +35 -33
- package/frontend-vue/app/components/blocks/RetentionInput.vue +51 -20
- package/frontend-vue/app/components/blocks/RouteTester.vue +86 -28
- package/frontend-vue/app/components/blocks/RouteTree.vue +9 -9
- package/frontend-vue/app/components/blocks/ScopeChip.vue +11 -7
- package/frontend-vue/app/composables/useClientValue.ts +18 -0
- package/frontend-vue/app/composables/useRouteDetail.ts +22 -106
- package/frontend-vue/app/utils/http.ts +10 -0
- package/frontend-vue/app/utils/testerRequest.ts +9 -7
- package/frontend-vue/dms.server.ts +9 -0
- package/frontend-vue/package.json +1 -1
- package/frontend-vue/server/tester.ts +266 -0
- package/frontend-vue/tests/clientValue.test.ts +64 -0
- package/frontend-vue/tests/dmsServer.test.ts +44 -0
- package/frontend-vue/tests/testerRequest.test.ts +1 -1
- package/frontend-vue/tests/testerRoute.test.ts +299 -0
- package/package.json +29 -13
- package/skills/dms-api/SKILL.md +31 -0
- package/frontend-vue/app/composables/useApiResource.ts +0 -92
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "API console for the AntelopeJS DMS: API health, request logs, per-route statistics, inferred contracts and a request tester.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"antelopejs",
|
|
7
|
+
"api",
|
|
8
|
+
"dms",
|
|
9
|
+
"dms-module",
|
|
10
|
+
"monitoring",
|
|
11
|
+
"request-logs"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://dms.antelopejs.com/docs/modules/api",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/AntelopeJS/dms-api/issues"
|
|
16
|
+
},
|
|
4
17
|
"license": "Apache-2.0",
|
|
5
18
|
"repository": {
|
|
6
19
|
"type": "git",
|
|
@@ -8,7 +21,8 @@
|
|
|
8
21
|
},
|
|
9
22
|
"files": [
|
|
10
23
|
"dist",
|
|
11
|
-
"frontend-vue"
|
|
24
|
+
"frontend-vue",
|
|
25
|
+
"skills"
|
|
12
26
|
],
|
|
13
27
|
"main": "dist/index.js",
|
|
14
28
|
"publishConfig": {
|
|
@@ -31,20 +45,19 @@
|
|
|
31
45
|
"knip:all": "knip"
|
|
32
46
|
},
|
|
33
47
|
"dependencies": {
|
|
34
|
-
"@antelopejs/interface-api": ">=0.0.
|
|
35
|
-
"@antelopejs/interface-api-util": ">=0.1.
|
|
36
|
-
"@antelopejs/interface-core": ">=0.
|
|
37
|
-
"@antelopejs/interface-database": ">=0.1.
|
|
38
|
-
"@antelopejs/interface-database-decorators": ">=0.1.
|
|
39
|
-
"@antelopejs/interface-dms": ">=0.
|
|
48
|
+
"@antelopejs/interface-api": ">=0.0.15 <1.0.0",
|
|
49
|
+
"@antelopejs/interface-api-util": ">=0.1.3 <1.0.0",
|
|
50
|
+
"@antelopejs/interface-core": ">=0.2.4 <1.0.0",
|
|
51
|
+
"@antelopejs/interface-database": ">=0.1.10 <1.0.0",
|
|
52
|
+
"@antelopejs/interface-database-decorators": ">=0.1.9 <1.0.0",
|
|
53
|
+
"@antelopejs/interface-dms": ">=0.7.2 <1.0.0",
|
|
40
54
|
"node-cron": "^4.2.1",
|
|
41
55
|
"zod": "^3.24.2"
|
|
42
56
|
},
|
|
43
57
|
"devDependencies": {
|
|
44
|
-
"@antelopejs/core": "1.
|
|
45
|
-
"@antelopejs/tooling-configs": ">=0.0.
|
|
58
|
+
"@antelopejs/core": "1.16.0",
|
|
59
|
+
"@antelopejs/tooling-configs": ">=0.0.9 <1.0.0",
|
|
46
60
|
"@types/node": "^24.0.0",
|
|
47
|
-
"@types/node-cron": "^3.0.11",
|
|
48
61
|
"knip": "^6.34.0",
|
|
49
62
|
"oxfmt": "^0.66.0",
|
|
50
63
|
"oxlint": "1.81.0",
|
|
@@ -56,7 +69,7 @@
|
|
|
56
69
|
"vitest": "^3.2.4"
|
|
57
70
|
},
|
|
58
71
|
"optionalDependencies": {
|
|
59
|
-
"@antelopejs/interface-dms-automation": ">=0.
|
|
72
|
+
"@antelopejs/interface-dms-automation": ">=0.2.1 <1.0.0"
|
|
60
73
|
},
|
|
61
74
|
"packageManager": "pnpm@10.6.5",
|
|
62
75
|
"antelopeJs": {
|
|
@@ -65,6 +78,9 @@
|
|
|
65
78
|
"@/*": [
|
|
66
79
|
"*"
|
|
67
80
|
]
|
|
68
|
-
}
|
|
81
|
+
},
|
|
82
|
+
"skills": [
|
|
83
|
+
"./skills"
|
|
84
|
+
]
|
|
69
85
|
}
|
|
70
86
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dms-api
|
|
3
|
+
description: Uses the @antelopejs/dms-api console of the AntelopeJS DMS (API health, request logs, per-route statistics, inferred route docs and a tester under /modules/api). Use when installing or configuring dms-api (retention, slow threshold, captured headers, testerSourceSecret), debugging a failing or slow route from its request logs, wiring its automation nodes (api.route-unhealthy, api.get-api-health, api.query-request-logs), or when a route is missing from the console.
|
|
4
|
+
icon: i-lucide-webhook
|
|
5
|
+
category: monitoring
|
|
6
|
+
tags: [api, monitoring, request-logs, routes, tester, automation]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# dms-api
|
|
10
|
+
|
|
11
|
+
Monitors the project's own HTTP API: it captures each request of the routes in scope, rolls them into per-route statistics, and infers each route's contract from its handler and traffic. It is a dashboard, not the HTTP server: the project still needs `@antelopejs/api`. User docs: https://dms.antelopejs.com/docs/modules/api (source: `docs/` of this package).
|
|
12
|
+
|
|
13
|
+
## When to reach for it
|
|
14
|
+
|
|
15
|
+
- Debug a route: read its failed requests in `/modules/api/logs` (the side panel holds the error, stack, headers and bodies) or replay one in the route's Tester.
|
|
16
|
+
- Alert on a broken route: an automation procedure on `api.route-unhealthy` (`flags`: `broken`, `slow`, `warn`; default `broken` + `slow`).
|
|
17
|
+
|
|
18
|
+
## Config (`antelope.config.ts`; the API settings page overrides it at runtime)
|
|
19
|
+
|
|
20
|
+
`statisticsLifetime` (ms, 30/60/90 days only), `requestLogRetention` (ms, 1–366 days), `requestSlownessThreshold` (ms, steps of 50), `requestLogMaxBodySize` (bytes), `requestLogCaptureHeaders` (lower case), `authMiddlewareNamePatterns`, `authMiddlewareCallbacks`, `testerSourceSecret` (same value on every instance). The module refuses to start with a value its settings page would refuse.
|
|
21
|
+
|
|
22
|
+
## Gotchas
|
|
23
|
+
|
|
24
|
+
- Scope defaults to **Own routes**: routes a module registers show only under Module routes or All routes.
|
|
25
|
+
- Its own calls, the DMS's calls and Tester calls are never counted in statistics or health.
|
|
26
|
+
- cURL snippets use the DMS `apiBaseUrl`: set it to the public API origin.
|
|
27
|
+
- The Tester forwards calls through the module's own frontend server route `POST /api/_dms-api/tester` (`frontend-vue/dms.server.ts`); dms-frontend 0.6 has no built-in tester route.
|
|
28
|
+
- Version 0.4+ needs `@antelopejs/dms` 0.9 (`interface-dms` 0.7) and `@antelopejs/dms-frontend` 0.6; 0.3 is the DMS 0.8 line.
|
|
29
|
+
- A route reads "Auth unknown" when the check happens inside the handler; guard with the DMS auth decorators or name the middleware in `authMiddlewareCallbacks`.
|
|
30
|
+
- Each block is its own permission (`@AuthUserWithPermission(<block>)`): grant roles the blocks they need.
|
|
31
|
+
- Request logs can hold application data; secret-looking keys are always redacted.
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, ref, shallowRef, watch, type Ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
export interface ApiResource<T> {
|
|
4
|
-
data: Ref<T | null>
|
|
5
|
-
error: Ref<unknown>
|
|
6
|
-
/** First load still running: nothing to show yet. */
|
|
7
|
-
pending: Ref<boolean>
|
|
8
|
-
/** A refresh is running over data already on screen. */
|
|
9
|
-
refreshing: Ref<boolean>
|
|
10
|
-
/** When the data on screen was received. */
|
|
11
|
-
receivedAt: Ref<number | null>
|
|
12
|
-
refresh: () => Promise<void>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A backend payload that follows a URL. A failed refresh keeps the last data
|
|
17
|
-
* on screen and says so through `error`, instead of replacing the page with
|
|
18
|
-
* an error box; a newer request cancels the one still running.
|
|
19
|
-
*/
|
|
20
|
-
export function useApiResource<T>(
|
|
21
|
-
url: () => string | null | undefined,
|
|
22
|
-
): ApiResource<T> {
|
|
23
|
-
const { $authFetch } = useAuthFetch()
|
|
24
|
-
const data = shallowRef<T | null>(null)
|
|
25
|
-
const error = ref<unknown>(null)
|
|
26
|
-
const pending = ref(true)
|
|
27
|
-
const refreshing = ref(false)
|
|
28
|
-
const receivedAt = ref<number | null>(null)
|
|
29
|
-
let controller: AbortController | null = null
|
|
30
|
-
|
|
31
|
-
async function load(target: string | null | undefined) {
|
|
32
|
-
controller?.abort()
|
|
33
|
-
if (!target) {
|
|
34
|
-
data.value = null
|
|
35
|
-
pending.value = false
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
const current = new AbortController()
|
|
39
|
-
controller = current
|
|
40
|
-
refreshing.value = data.value !== null
|
|
41
|
-
try {
|
|
42
|
-
const response = await $authFetch<T>(target, { signal: current.signal })
|
|
43
|
-
if (controller !== current) return
|
|
44
|
-
data.value = response
|
|
45
|
-
error.value = null
|
|
46
|
-
receivedAt.value = Date.now()
|
|
47
|
-
} catch (cause) {
|
|
48
|
-
if (controller !== current) return
|
|
49
|
-
if ((cause as { name?: string })?.name !== 'AbortError')
|
|
50
|
-
error.value = cause
|
|
51
|
-
} finally {
|
|
52
|
-
if (controller === current) {
|
|
53
|
-
pending.value = false
|
|
54
|
-
refreshing.value = false
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
watch(url, (target, previous) => {
|
|
60
|
-
if (target === previous) return
|
|
61
|
-
pending.value = true
|
|
62
|
-
data.value = null
|
|
63
|
-
void load(target)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (import.meta.env.SSR) {
|
|
67
|
-
pending.value = true
|
|
68
|
-
} else {
|
|
69
|
-
void load(url())
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
onBeforeUnmount(() => controller?.abort())
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
data,
|
|
76
|
-
error,
|
|
77
|
-
pending,
|
|
78
|
-
refreshing,
|
|
79
|
-
receivedAt,
|
|
80
|
-
refresh: () => load(url()),
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** The HTTP status of a failed request, when it has one. */
|
|
85
|
-
export function errorStatus(error: unknown): number | undefined {
|
|
86
|
-
const value = error as {
|
|
87
|
-
statusCode?: number
|
|
88
|
-
status?: number
|
|
89
|
-
response?: { status?: number }
|
|
90
|
-
}
|
|
91
|
-
return value?.statusCode ?? value?.status ?? value?.response?.status
|
|
92
|
-
}
|