@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
package/README.md
CHANGED
|
@@ -6,9 +6,57 @@
|
|
|
6
6
|
<a href="https://antelopejs.com"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
`@antelopejs/dms-api` adds API
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
`@antelopejs/dms-api` adds an API console to the AntelopeJS DMS. Open
|
|
10
|
+
**Modules → API** (`/modules/api`):
|
|
11
|
+
|
|
12
|
+
- **Overview**: is the API healthy, since when and why not, with traffic,
|
|
13
|
+
errors, the routes needing attention and the slowest ones.
|
|
14
|
+
- **Request logs**: every captured request, filtered by status class, method,
|
|
15
|
+
slowness or period; a request opens with its error, timing, headers and
|
|
16
|
+
bodies, and can be replayed in the tester.
|
|
17
|
+
- **Routes**: every registered route with its statistics, its contract
|
|
18
|
+
(inferred from its code and its traffic) and a tester.
|
|
19
|
+
- **API settings**: the routes the console watches, retention, captured
|
|
20
|
+
headers and the slow threshold.
|
|
21
|
+
|
|
22
|
+
It requires `@antelopejs/dms` `>=0.8.0 <0.9.0` (`@antelopejs/interface-dms`
|
|
23
|
+
0.6.0) and `@antelopejs/dms-frontend` `>=0.5.2 <0.6.0`. These DMS releases
|
|
24
|
+
bring the pieces the console is built on: the row side panel, the page's
|
|
25
|
+
Live / Pause state and its holds, the refresh the console's own blocks share
|
|
26
|
+
with the DMS blocks, the period kept in the URL, the column tones, the
|
|
27
|
+
`Guard` block, the form API its settings fields use and the redirect of
|
|
28
|
+
`/modules/api` to the Overview.
|
|
29
|
+
|
|
30
|
+
The Overview, the Request logs and Routes have the DMS **Live / Pause**
|
|
31
|
+
toggle (the L key). Live, the default, the page follows new requests as the
|
|
32
|
+
DMS realtime channel announces them, each block, the console's own included,
|
|
33
|
+
read again at most every 5 s (Request logs), 10 s (Overview) or 15 s
|
|
34
|
+
(Routes), every minute once the Overview or Routes show a week or more, and
|
|
35
|
+
on that clock while the realtime channel is down. Paused, nothing is read:
|
|
36
|
+
the toggle says what was missed ("Paused · 40 new requests · 2 in 5xx"), the
|
|
37
|
+
request tables keep their rows, search, sort and "Load more" included, and
|
|
38
|
+
offer "40 new requests · 2 in 5xx · Show"; resuming reads each block once.
|
|
39
|
+
The page also pauses by itself while its browser tab is hidden and while you
|
|
40
|
+
type in the Tester, and a request table holds its rows while one of them is
|
|
41
|
+
open in the side panel (and, in the Request logs, while you read further
|
|
42
|
+
down, search or sort otherwise than newest first), saying why ("Table on
|
|
43
|
+
hold · search active"). The choice is one for the three pages, and
|
|
44
|
+
`?live=0` opens a page paused.
|
|
45
|
+
|
|
46
|
+
A request opens in a side panel on the right, on a single click on its row,
|
|
47
|
+
from every request table: the panel is titled with its method and path, J / K
|
|
48
|
+
step through the rows shown, and the URL names it (`?record=`), so a link or a
|
|
49
|
+
reload opens it again. In the Request logs, `/` opens the search and `?` the
|
|
50
|
+
list of shortcuts; in Routes, `/` opens the route filter. The DMS Shortcuts
|
|
51
|
+
page lists them. The period of a page is its period selector's (1H, 24H, 7D,
|
|
52
|
+
30D, and "All time" in the Request logs), kept in the URL
|
|
53
|
+
(`?api.period=last-24h`); without one, the page opens on the last period
|
|
54
|
+
picked on any of the three pages, else the last 24 hours. An incident of the
|
|
55
|
+
Overview opens the Request logs narrowed to its own range
|
|
56
|
+
(`?since=&until=`), a linked filter within the page's period. The tabs of a
|
|
57
|
+
route are named in the URL by their slot (`?tab=tester`).
|
|
58
|
+
Dates and times follow the user's Language & region preferences (time zone,
|
|
59
|
+
clock, date format), on a 24-hour clock by default.
|
|
12
60
|
|
|
13
61
|
This module is the dashboard for your API, not the HTTP server implementation.
|
|
14
62
|
Your application still needs an API provider such as `@antelopejs/api`, the
|
|
@@ -45,7 +93,46 @@ its Vue 3 Inertia frontend module automatically through
|
|
|
45
93
|
statistics and request-log retention, the slow-request threshold, body-size
|
|
46
94
|
limits, and the header capture allowlist. Retention uses milliseconds; body
|
|
47
95
|
limits use bytes. Settings saved through the dashboard override the module
|
|
48
|
-
configuration at runtime.
|
|
96
|
+
configuration at runtime. A field set back to its module default ("Use
|
|
97
|
+
default") holds no override; the retentions have no such button, since
|
|
98
|
+
lowering one deletes data. An empty list of captured headers is an override
|
|
99
|
+
of its own: no header is captured.
|
|
100
|
+
|
|
101
|
+
The cURL and fetch snippets of a route and a request are written against the
|
|
102
|
+
DMS's public API origin, its `apiBaseUrl` (read through `GetApiBaseUrl()`):
|
|
103
|
+
set it to the URL clients reach the API at, such as `https://api.example.com`.
|
|
104
|
+
Under `ajs dms dev` it follows the dev server.
|
|
105
|
+
|
|
106
|
+
Statistics are kept 90 days by default, and the dashboard offers 30, 60 or
|
|
107
|
+
90 days. The 30D period compares itself with the 30 days before it, so it
|
|
108
|
+
needs 60 days or more: with 30 days, the 30D comparison is unavailable.
|
|
109
|
+
Request logs, which hold full requests, are kept 30 days by default,
|
|
110
|
+
independently of the statistics. Lowering a retention from the dashboard shows how much the
|
|
111
|
+
next hourly prune deletes and asks to confirm it.
|
|
112
|
+
|
|
113
|
+
The module configuration follows the dashboard's rules: the module does not
|
|
114
|
+
start with a value the Settings page would refuse (statistics kept other than
|
|
115
|
+
30, 60 or 90 days, a slow threshold off its 50 ms step, a body cap or a log
|
|
116
|
+
retention out of bounds, a secret header to capture).
|
|
117
|
+
|
|
118
|
+
The console only counts your API's traffic. Its own calls (`/api/monitoring`),
|
|
119
|
+
the DMS's (`/dms`, the realtime channel, the page layouts, the session check,
|
|
120
|
+
its Settings pages and their tables) and the DMS console's pages are neither
|
|
121
|
+
logged nor counted. Requests sent from the Tester are logged, marked as such,
|
|
122
|
+
but left out of the statistics, the health and the incidents. The Tester marks
|
|
123
|
+
its calls with a short-lived token the module signs
|
|
124
|
+
(`x-antelopejs-api-source`), which only a user allowed to use the Tester
|
|
125
|
+
obtains: a client cannot leave the statistics by declaring itself the Tester.
|
|
126
|
+
Behind several instances, give them the same `testerSourceSecret` so each one
|
|
127
|
+
accepts the tokens of the others.
|
|
128
|
+
|
|
129
|
+
### Upgrading from 0.1
|
|
130
|
+
|
|
131
|
+
The stored data of earlier versions is not migrated. Drop the
|
|
132
|
+
`request_log`, `routes_statistics` and `migrations` tables of the `dms-api`
|
|
133
|
+
schema when upgrading; the module creates them again. The API settings answer
|
|
134
|
+
the error-rate thresholds as ratios (`0.05`), and the `api.get-api-health`
|
|
135
|
+
automation answers `failingRoutes` instead of `routesWithErrors24h`.
|
|
49
136
|
|
|
50
137
|
Request logs can contain application data. Review the capture and retention
|
|
51
138
|
settings before collecting real traffic, and use synthetic requests for
|
|
@@ -56,8 +143,12 @@ screenshots or shared demos. The module prunes logs and statistics hourly.
|
|
|
56
143
|
Use the pnpm version declared in `package.json`. The repository's `dev` script
|
|
57
144
|
starts its playground backend; `frontend:dev` starts the published Inertia
|
|
58
145
|
dashboard loader. The playground connects to MongoDB at
|
|
59
|
-
`mongodb://localhost:27017` unless `MONGO_URL` points it elsewhere. `pnpm
|
|
146
|
+
`mongodb://localhost:27017` unless `MONGO_URL` points it elsewhere. Run `pnpm --dir playground traffic` while the playground runs to send
|
|
147
|
+
its demo storefront routes a few hundred requests (healthy, slow, failing and
|
|
148
|
+
client errors), so every page has something to show. `pnpm build`
|
|
60
149
|
compiles the backend, and `pnpm test` runs the backend unit tests (`tests/`)
|
|
61
|
-
followed by the frontend test suite
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
followed by the frontend test suite, and `pnpm knip` checks the dependencies
|
|
151
|
+
of both. To build and typecheck the frontend module against the installed
|
|
152
|
+
DMS, run `pnpm exec ajs dms verify-source -m ../frontend-vue` from
|
|
153
|
+
`playground/`; or set `DMS_FRONTEND_WORKSPACE` to the workspace generated by
|
|
154
|
+
`ajs dms prepare`, then run `pnpm --dir frontend-vue typecheck`.
|
|
@@ -4,6 +4,7 @@ exports.getApiHealthAction = void 0;
|
|
|
4
4
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
5
5
|
const db_1 = require("@/db");
|
|
6
6
|
const statistics_aggregate_1 = require("@/services/statistics-aggregate");
|
|
7
|
+
const route_catalog_1 = require("@/services/route-catalog");
|
|
7
8
|
const scope_1 = require("./scope");
|
|
8
9
|
exports.getApiHealthAction = {
|
|
9
10
|
id: "api.get-api-health",
|
|
@@ -25,7 +26,7 @@ exports.getApiHealthAction = {
|
|
|
25
26
|
type: "object",
|
|
26
27
|
properties: {
|
|
27
28
|
totalRoutes: { type: "number" },
|
|
28
|
-
|
|
29
|
+
failingRoutes: { type: "number" },
|
|
29
30
|
slowRoutesCount: { type: "number" },
|
|
30
31
|
averageLatencyMs: { type: "number" },
|
|
31
32
|
callsToday: { type: "number" },
|
|
@@ -43,9 +44,9 @@ exports.getApiHealthAction = {
|
|
|
43
44
|
},
|
|
44
45
|
async execute(input) {
|
|
45
46
|
const keys = await (0, scope_1.activeScopeKeys)();
|
|
46
|
-
const totalRoutes =
|
|
47
|
+
const totalRoutes = (0, route_catalog_1.countRoutes)(keys);
|
|
47
48
|
const statsModel = (0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel);
|
|
48
|
-
const kpis = await (0, statistics_aggregate_1.getSummaryKpis)(statsModel, totalRoutes, keys);
|
|
49
|
+
const kpis = await (0, statistics_aggregate_1.getSummaryKpis)({ logs: (0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), stats: statsModel }, totalRoutes, keys);
|
|
49
50
|
const statusBreakdown = await (0, statistics_aggregate_1.getStatusBreakdown)(statsModel, input.days, keys);
|
|
50
51
|
return { ...kpis, statusBreakdown };
|
|
51
52
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-api-health.js","sourceRoot":"","sources":["../../src/automation/get-api-health.ts"],"names":[],"mappings":";;;AA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GAAE,CAAC;QACrC,MAAM,WAAW,GAAG,IAAA,2BAAW,EAAC,IAAI,CAAC,CAAC;QACtC,MAAM,UAAU,GAAG,IAAA,wCAAQ,EAAC,yBAAoB,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,MAAM,IAAA,qCAAc,EAC/B,EAAE,IAAI,EAAE,IAAA,wCAAQ,EAAC,oBAAe,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EACtD,WAAW,EACX,IAAI,CACL,CAAC;QACF,MAAM,eAAe,GAAG,MAAM,IAAA,yCAAkB,EAC9C,UAAU,EACV,KAAK,CAAC,IAAI,EACV,IAAI,CACL,CAAC;QACF,OAAO,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,CAAC;IACtC,CAAC;CACF,CAAC"}
|
|
@@ -12,7 +12,7 @@ const DEFAULT_FLAGS = ["broken", "slow"];
|
|
|
12
12
|
exports.routeUnhealthyTrigger = {
|
|
13
13
|
id: "api.route-unhealthy",
|
|
14
14
|
name: "Route unhealthy",
|
|
15
|
-
description: "Fires when a route
|
|
15
|
+
description: "Fires when a route enters a monitored bad state by the API health rules: broken (failing on its 5xx rate), slow (p95 at or above the slow threshold) or warn (many 4xx)",
|
|
16
16
|
icon: "i-ph-warning",
|
|
17
17
|
cluster: "singleton",
|
|
18
18
|
configSchema: {
|
|
@@ -61,7 +61,7 @@ exports.routeUnhealthyTrigger = {
|
|
|
61
61
|
polling = true;
|
|
62
62
|
try {
|
|
63
63
|
const keys = await (0, scope_1.activeScopeKeys)();
|
|
64
|
-
const items = await (0, statistics_aggregate_1.getWatchList)((0, interface_database_decorators_1.GetModel)(db_1.
|
|
64
|
+
const items = await (0, statistics_aggregate_1.getWatchList)((0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), Number.POSITIVE_INFINITY, keys);
|
|
65
65
|
const seen = new Set();
|
|
66
66
|
for (const item of items) {
|
|
67
67
|
seen.add(item.routeKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-unhealthy.js","sourceRoot":"","sources":["../../src/automation/route-unhealthy.ts"],"names":[],"mappings":";;;AAAA,gEAA6D;AAC7D,6FAAqE;AAErE,
|
|
1
|
+
{"version":3,"file":"route-unhealthy.js","sourceRoot":"","sources":["../../src/automation/route-unhealthy.ts"],"names":[],"mappings":";;;AAAA,gEAA6D;AAC7D,6FAAqE;AAErE,6BAAuC;AACvC,0EAGyC;AACzC,mCAA0C;AAkB1C,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,aAAa,GAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEpC,QAAA,qBAAqB,GAG9B;IACF,EAAE,EAAE,qBAAqB;IACzB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,yKAAyK;IAC3K,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,yBAAyB;gBAChC,OAAO,EAAE,wBAAwB;gBACjC,OAAO,EAAE,oBAAoB;aAC9B;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,gBAAgB;gBACvB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;gBAC3D,OAAO,EAAE,aAAa;aACvB;SACF;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACvB,IAAI,EAA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@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.activeScopeKeys = activeScopeKeys;
|
|
4
|
-
exports.countScopedRoutes = countScopedRoutes;
|
|
5
4
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
6
5
|
const db_1 = require("@/db");
|
|
7
6
|
const scope_1 = require("@/services/scope");
|
|
@@ -9,10 +8,4 @@ const settings_1 = require("@/services/settings");
|
|
|
9
8
|
async function activeScopeKeys() {
|
|
10
9
|
return (0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)());
|
|
11
10
|
}
|
|
12
|
-
async function countScopedRoutes(keys) {
|
|
13
|
-
if (keys)
|
|
14
|
-
return keys.size;
|
|
15
|
-
const all = await (0, interface_database_decorators_1.GetModel)(db_1.RouteModel).getAll();
|
|
16
|
-
return all.length;
|
|
17
|
-
}
|
|
18
11
|
//# sourceMappingURL=scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/automation/scope.ts"],"names":[],"mappings":";;AASA,0CAEC;
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/automation/scope.ts"],"names":[],"mappings":";;AASA,0CAEC;AAXD,6FAAqE;AACrE,6BAAkC;AAClC,4CAAsD;AACtD,kDAAqD;AAM9C,KAAK,UAAU,eAAe;IACnC,OAAO,IAAA,0BAAkB,EAAC,IAAA,wCAAQ,EAAC,eAAU,CAAC,EAAE,IAAA,yBAAc,GAAE,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const STATISTICS_LIFETIME_DAY_CHOICES: readonly [30, 60, 90];
|
|
2
|
+
export declare const DEFAULT_STATISTICS_LIFETIME_DAYS = 90;
|
|
1
3
|
export interface DmsApiConfig {
|
|
2
4
|
statisticsLifetime: number;
|
|
3
5
|
requestSlownessThreshold: number;
|
|
@@ -6,7 +8,9 @@ export interface DmsApiConfig {
|
|
|
6
8
|
requestLogCaptureHeaders: string[];
|
|
7
9
|
authMiddlewareNamePatterns: string[];
|
|
8
10
|
authMiddlewareCallbacks: string[];
|
|
11
|
+
testerSourceSecret?: string;
|
|
9
12
|
}
|
|
10
13
|
export declare function setConfig(input?: Partial<DmsApiConfig>): void;
|
|
11
14
|
export declare function applyConfigOverrides(overrides: Partial<DmsApiConfig>): void;
|
|
12
15
|
export declare function getConfig(): DmsApiConfig;
|
|
16
|
+
export declare function getBaseConfig(): DmsApiConfig;
|
package/dist/config.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_STATISTICS_LIFETIME_DAYS = exports.STATISTICS_LIFETIME_DAY_CHOICES = void 0;
|
|
3
4
|
exports.setConfig = setConfig;
|
|
4
5
|
exports.applyConfigOverrides = applyConfigOverrides;
|
|
5
6
|
exports.getConfig = getConfig;
|
|
6
|
-
|
|
7
|
+
exports.getBaseConfig = getBaseConfig;
|
|
7
8
|
const constants_1 = require("./types/constants");
|
|
9
|
+
exports.STATISTICS_LIFETIME_DAY_CHOICES = [30, 60, 90];
|
|
10
|
+
exports.DEFAULT_STATISTICS_LIFETIME_DAYS = 90;
|
|
8
11
|
const DEFAULT_CONFIG = {
|
|
9
|
-
statisticsLifetime: constants_1.
|
|
12
|
+
statisticsLifetime: exports.DEFAULT_STATISTICS_LIFETIME_DAYS * constants_1.MS_PER_DAY,
|
|
10
13
|
requestSlownessThreshold: constants_1.SLOW_REQUEST_THRESHOLD_MS,
|
|
11
14
|
requestLogMaxBodySize: constants_1.REQUEST_LOG_MAX_BODY_BYTES,
|
|
12
|
-
requestLogRetention: constants_1.
|
|
15
|
+
requestLogRetention: constants_1.REQUEST_LOG_RETENTION_MS,
|
|
13
16
|
requestLogCaptureHeaders: [...constants_1.REQUEST_LOG_DEFAULT_HEADERS],
|
|
14
17
|
authMiddlewareNamePatterns: ["^auth_", "^requireAuth", "^session_"],
|
|
15
18
|
authMiddlewareCallbacks: [],
|
|
@@ -17,15 +20,15 @@ const DEFAULT_CONFIG = {
|
|
|
17
20
|
let baseConfig = DEFAULT_CONFIG;
|
|
18
21
|
let globalConfig = DEFAULT_CONFIG;
|
|
19
22
|
let runtimeOverrides = {};
|
|
23
|
+
function overlay(layer, base) {
|
|
24
|
+
const defined = Object.fromEntries(Object.entries(layer).filter(([, value]) => value !== undefined));
|
|
25
|
+
return { ...base, ...defined };
|
|
26
|
+
}
|
|
20
27
|
function mergeEffective() {
|
|
21
|
-
globalConfig = (
|
|
28
|
+
globalConfig = overlay(runtimeOverrides, baseConfig);
|
|
22
29
|
}
|
|
23
30
|
function setConfig(input) {
|
|
24
|
-
|
|
25
|
-
if (input?.requestLogRetention === undefined) {
|
|
26
|
-
merged.requestLogRetention = merged.statisticsLifetime;
|
|
27
|
-
}
|
|
28
|
-
baseConfig = merged;
|
|
31
|
+
baseConfig = overlay(input ?? {}, DEFAULT_CONFIG);
|
|
29
32
|
mergeEffective();
|
|
30
33
|
}
|
|
31
34
|
function applyConfigOverrides(overrides) {
|
|
@@ -35,4 +38,7 @@ function applyConfigOverrides(overrides) {
|
|
|
35
38
|
function getConfig() {
|
|
36
39
|
return globalConfig;
|
|
37
40
|
}
|
|
41
|
+
function getBaseConfig() {
|
|
42
|
+
return baseConfig;
|
|
43
|
+
}
|
|
38
44
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAgFA,8BAGC;AAMD,oDAGC;AAED,8BAEC;AAGD,s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Y,CAAC;AACtB,CAAC;AAGD,SAAgB,aAAa;IAC3B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { type RequestLogStatusClass } from "./request_log.status";
|
|
2
|
+
export { pathEncoded, requestIdPrefix, searchPattern, } from "./request_log.search";
|
|
3
|
+
export { type RequestLogStatusClass } from "./request_log.status";
|
|
1
4
|
import { RequestLog } from "../tables/request_log.table";
|
|
2
|
-
export type RequestLogStatusClass = "success" | "client-error" | "server-error";
|
|
3
5
|
export interface RequestLogFilters {
|
|
4
6
|
routeId?: string;
|
|
5
7
|
uri?: string;
|
|
8
|
+
rawPath?: string;
|
|
6
9
|
method?: string;
|
|
10
|
+
methods?: string[];
|
|
11
|
+
routeMethod?: string;
|
|
12
|
+
errorMessage?: string;
|
|
7
13
|
statusClass?: RequestLogStatusClass;
|
|
8
14
|
statusMin?: number;
|
|
9
15
|
statusMax?: number;
|
|
10
16
|
slowThresholdMs?: number;
|
|
11
17
|
search?: string;
|
|
18
|
+
requestId?: string;
|
|
12
19
|
since?: Date;
|
|
13
20
|
until?: Date;
|
|
21
|
+
apiTrafficOnly?: boolean;
|
|
22
|
+
testerOnly?: boolean;
|
|
14
23
|
cursor?: string;
|
|
15
24
|
limit?: number;
|
|
16
25
|
routeKeys?: string[];
|
|
@@ -19,6 +28,28 @@ export interface RequestLogPage {
|
|
|
19
28
|
results: RequestLog[];
|
|
20
29
|
nextCursor: string | null;
|
|
21
30
|
}
|
|
31
|
+
export type RequestLogListItem = Pick<RequestLog, "_id" | "timestamp" | "method" | "uri" | "rawPath" | "statusCode" | "responseTimeMs" | "ip" | "routeMethod" | "source" | "requestId"> & {
|
|
32
|
+
errorMessage?: string | null;
|
|
33
|
+
};
|
|
34
|
+
export interface RequestLogListPage {
|
|
35
|
+
results: RequestLogListItem[];
|
|
36
|
+
total: number;
|
|
37
|
+
}
|
|
38
|
+
export type RequestLogSortKey = "timestamp" | "statusCode" | "responseTimeMs";
|
|
39
|
+
export interface RequestLogListOptions {
|
|
40
|
+
offset?: number;
|
|
41
|
+
limit?: number;
|
|
42
|
+
sortKey?: RequestLogSortKey;
|
|
43
|
+
sortDirection?: "asc" | "desc";
|
|
44
|
+
}
|
|
45
|
+
export interface RequestLogSample {
|
|
46
|
+
timestamp: Date;
|
|
47
|
+
method: string;
|
|
48
|
+
uri: string;
|
|
49
|
+
statusCode: number;
|
|
50
|
+
responseTimeMs: number | null;
|
|
51
|
+
errorMessage?: string;
|
|
52
|
+
}
|
|
22
53
|
export declare const REQUEST_LOG_MAX_LIMIT = 200;
|
|
23
54
|
declare const RequestLogModel_base: {
|
|
24
55
|
new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
|
|
@@ -40,8 +71,12 @@ declare const RequestLogModel_base: {
|
|
|
40
71
|
};
|
|
41
72
|
export declare class RequestLogModel extends RequestLogModel_base {
|
|
42
73
|
query(filters: RequestLogFilters): Promise<RequestLogPage>;
|
|
74
|
+
list(filters: RequestLogFilters, options: RequestLogListOptions): Promise<RequestLogListPage>;
|
|
75
|
+
samples(filters: RequestLogFilters): Promise<RequestLogSample[]>;
|
|
76
|
+
private listItems;
|
|
77
|
+
private applyFilters;
|
|
43
78
|
private applyScalarFilters;
|
|
79
|
+
private applySearch;
|
|
44
80
|
private applyStatusFilters;
|
|
45
81
|
deleteOlderThan(cutoff: Date): Promise<number>;
|
|
46
82
|
}
|
|
47
|
-
export {};
|
|
@@ -1,61 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestLogModel = exports.REQUEST_LOG_MAX_LIMIT = void 0;
|
|
3
|
+
exports.RequestLogModel = exports.REQUEST_LOG_MAX_LIMIT = exports.searchPattern = exports.requestIdPrefix = exports.pathEncoded = void 0;
|
|
4
4
|
const interface_database_1 = require("@antelopejs/interface-database");
|
|
5
5
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
6
|
+
const constants_1 = require("../../types/constants");
|
|
7
|
+
const request_log_search_1 = require("./request_log.search");
|
|
8
|
+
const request_log_status_1 = require("./request_log.status");
|
|
9
|
+
var request_log_search_2 = require("./request_log.search");
|
|
10
|
+
Object.defineProperty(exports, "pathEncoded", { enumerable: true, get: function () { return request_log_search_2.pathEncoded; } });
|
|
11
|
+
Object.defineProperty(exports, "requestIdPrefix", { enumerable: true, get: function () { return request_log_search_2.requestIdPrefix; } });
|
|
12
|
+
Object.defineProperty(exports, "searchPattern", { enumerable: true, get: function () { return request_log_search_2.searchPattern; } });
|
|
6
13
|
const request_log_table_1 = require("../tables/request_log.table");
|
|
14
|
+
const routes_statistics_table_1 = require("../tables/routes_statistics.table");
|
|
7
15
|
const DEFAULT_LIMIT = 50;
|
|
16
|
+
const TESTER_SOURCE = "tester";
|
|
8
17
|
const CURSOR_SEPARATOR = "|";
|
|
9
18
|
function decodeCursor(raw) {
|
|
10
19
|
if (!raw)
|
|
11
20
|
return undefined;
|
|
12
21
|
const separator = raw.indexOf(CURSOR_SEPARATOR);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const timestamp = new Date(
|
|
22
|
+
if (separator < 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
const timestamp = new Date(raw.slice(0, separator));
|
|
25
|
+
const id = raw.slice(separator + 1);
|
|
16
26
|
if (Number.isNaN(+timestamp) || id === "")
|
|
17
27
|
return undefined;
|
|
18
28
|
return { timestamp, id };
|
|
19
29
|
}
|
|
20
30
|
exports.REQUEST_LOG_MAX_LIMIT = 200;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"client-error": { min: 400, max: 500 },
|
|
24
|
-
"server-error": { min: 500 },
|
|
25
|
-
};
|
|
26
|
-
function escapeRegex(input) {
|
|
27
|
-
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
|
+
function logCursor(log) {
|
|
32
|
+
return `${log.timestamp.toISOString()}${CURSOR_SEPARATOR}${log._id}`;
|
|
28
33
|
}
|
|
29
34
|
function paginate(results, limit) {
|
|
30
35
|
if (results.length > limit) {
|
|
31
36
|
const trimmed = results.slice(0, limit);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
return {
|
|
38
|
+
results: trimmed,
|
|
39
|
+
nextCursor: logCursor(trimmed[trimmed.length - 1]),
|
|
40
|
+
};
|
|
35
41
|
}
|
|
36
42
|
return { results, nextCursor: null };
|
|
37
43
|
}
|
|
38
44
|
class RequestLogModel extends (0, interface_database_decorators_1.BasicDataModel)(request_log_table_1.RequestLog, request_log_table_1.requestLogTableName) {
|
|
39
45
|
async query(filters) {
|
|
40
46
|
const limit = Math.min(filters.limit ?? DEFAULT_LIMIT, exports.REQUEST_LOG_MAX_LIMIT);
|
|
41
|
-
|
|
42
|
-
q = this.applyScalarFilters(q, filters);
|
|
43
|
-
q = this.applyStatusFilters(q, filters);
|
|
47
|
+
const q = this.applyFilters(this.table.orderBy(request_log_table_1.REQUEST_LOG_ORDER_INDEX, "desc"), filters);
|
|
44
48
|
const results = await q.slice(0, limit + 1).run();
|
|
45
49
|
return paginate(results, limit);
|
|
46
50
|
}
|
|
51
|
+
async list(filters, options) {
|
|
52
|
+
const limit = Math.min(options.limit ?? DEFAULT_LIMIT, constants_1.REQUEST_LOG_LIST_MAX_ROWS);
|
|
53
|
+
const offset = Math.max(0, options.offset ?? 0);
|
|
54
|
+
const sortKey = options.sortKey ?? "timestamp";
|
|
55
|
+
const index = sortKey === "timestamp" ? request_log_table_1.REQUEST_LOG_ORDER_INDEX : sortKey;
|
|
56
|
+
const ordered = this.applyFilters(this.table.orderBy(index, options.sortDirection ?? "desc"), filters);
|
|
57
|
+
const [results, total] = await Promise.all([
|
|
58
|
+
limit > 0 ? this.listItems(ordered.slice(offset, offset + limit)) : [],
|
|
59
|
+
this.applyFilters(this.table, filters).count().run(),
|
|
60
|
+
]);
|
|
61
|
+
return { results, total };
|
|
62
|
+
}
|
|
63
|
+
async samples(filters) {
|
|
64
|
+
return this.applyFilters(this.table, { ...filters, apiTrafficOnly: true })
|
|
65
|
+
.map((doc) => ({
|
|
66
|
+
timestamp: doc.key("timestamp"),
|
|
67
|
+
method: doc.key("routeMethod").default(doc.key("method")),
|
|
68
|
+
uri: doc.key("uri"),
|
|
69
|
+
statusCode: doc.key("statusCode"),
|
|
70
|
+
responseTimeMs: doc.key("responseTimeMs"),
|
|
71
|
+
errorMessage: doc.key("error").default(null).key("message"),
|
|
72
|
+
}))
|
|
73
|
+
.run();
|
|
74
|
+
}
|
|
75
|
+
listItems(rows) {
|
|
76
|
+
return rows
|
|
77
|
+
.map((doc) => ({
|
|
78
|
+
_id: doc.key("_id"),
|
|
79
|
+
timestamp: doc.key("timestamp"),
|
|
80
|
+
method: doc.key("method"),
|
|
81
|
+
uri: doc.key("uri"),
|
|
82
|
+
rawPath: doc.key("rawPath"),
|
|
83
|
+
statusCode: doc.key("statusCode"),
|
|
84
|
+
responseTimeMs: doc.key("responseTimeMs"),
|
|
85
|
+
errorMessage: doc.key("error").default(null).key("message"),
|
|
86
|
+
ip: doc.key("ip"),
|
|
87
|
+
routeMethod: doc.key("routeMethod"),
|
|
88
|
+
source: doc.key("source"),
|
|
89
|
+
requestId: doc.key("requestId"),
|
|
90
|
+
}))
|
|
91
|
+
.run();
|
|
92
|
+
}
|
|
93
|
+
applyFilters(q, filters) {
|
|
94
|
+
return this.applyStatusFilters(this.applySearch(this.applyScalarFilters(q, filters), filters), filters);
|
|
95
|
+
}
|
|
47
96
|
applyScalarFilters(q, filters) {
|
|
48
97
|
const cursor = decodeCursor(filters.cursor);
|
|
49
98
|
if (cursor) {
|
|
50
|
-
q = q.filter((doc) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.and(doc.key("_id").lt(cursor.id)));
|
|
58
|
-
});
|
|
99
|
+
q = q.filter((doc) => doc
|
|
100
|
+
.key("timestamp")
|
|
101
|
+
.lt(cursor.timestamp)
|
|
102
|
+
.or(doc
|
|
103
|
+
.key("timestamp")
|
|
104
|
+
.eq(cursor.timestamp)
|
|
105
|
+
.and(doc.key("_id").lt(cursor.id))));
|
|
59
106
|
}
|
|
60
107
|
const since = filters.since;
|
|
61
108
|
if (since) {
|
|
@@ -63,38 +110,86 @@ class RequestLogModel extends (0, interface_database_decorators_1.BasicDataModel
|
|
|
63
110
|
}
|
|
64
111
|
const until = filters.until;
|
|
65
112
|
if (until) {
|
|
66
|
-
q = q.filter((doc) => doc.key("timestamp").
|
|
113
|
+
q = q.filter((doc) => doc.key("timestamp").lt(until));
|
|
114
|
+
}
|
|
115
|
+
if (filters.apiTrafficOnly) {
|
|
116
|
+
q = q.filter((doc) => doc.key("source").default("").eq(""));
|
|
117
|
+
}
|
|
118
|
+
if (filters.testerOnly) {
|
|
119
|
+
q = q.filter((doc) => doc.key("source").default("").eq(TESTER_SOURCE));
|
|
67
120
|
}
|
|
68
121
|
const routeId = filters.routeId;
|
|
69
122
|
if (routeId) {
|
|
70
123
|
q = q.filter((doc) => doc.key("routeId").eq(routeId));
|
|
71
124
|
}
|
|
72
|
-
|
|
73
|
-
|
|
125
|
+
if (filters.uri) {
|
|
126
|
+
const uri = (0, routes_statistics_table_1.normalizeRoutePath)(filters.uri);
|
|
74
127
|
q = q.filter((doc) => doc.key("uri").eq(uri));
|
|
75
128
|
}
|
|
76
129
|
if (filters.method) {
|
|
77
130
|
const method = filters.method.toUpperCase();
|
|
78
131
|
q = q.filter((doc) => doc.key("method").eq(method));
|
|
79
132
|
}
|
|
80
|
-
if (filters.
|
|
81
|
-
const
|
|
82
|
-
q = q.filter((doc) => doc.key("
|
|
133
|
+
if (filters.methods) {
|
|
134
|
+
const methods = filters.methods.map((method) => method.toUpperCase());
|
|
135
|
+
q = q.filter((doc) => interface_database_1.ValueProxy.constant(methods).includes(doc.key("method").cast()));
|
|
136
|
+
}
|
|
137
|
+
if (filters.routeMethod) {
|
|
138
|
+
const method = filters.routeMethod.toUpperCase();
|
|
139
|
+
q = q.filter((doc) => doc.key("routeMethod").default(doc.key("method")).eq(method));
|
|
140
|
+
}
|
|
141
|
+
const rawPath = filters.rawPath;
|
|
142
|
+
if (rawPath) {
|
|
143
|
+
q = q.filter((doc) => doc.key("rawPath").eq(rawPath));
|
|
144
|
+
}
|
|
145
|
+
const requestId = filters.requestId;
|
|
146
|
+
if (requestId) {
|
|
147
|
+
q = q.filter((doc) => doc.key("requestId").eq(requestId));
|
|
148
|
+
}
|
|
149
|
+
if (filters.errorMessage) {
|
|
150
|
+
const pattern = `(?i)${(0, request_log_search_1.escapeRegex)(filters.errorMessage)}`;
|
|
151
|
+
q = q.filter((doc) => doc
|
|
152
|
+
.key("error")
|
|
153
|
+
.default(null)
|
|
154
|
+
.key("message")
|
|
155
|
+
.default("")
|
|
156
|
+
.match(pattern));
|
|
83
157
|
}
|
|
84
158
|
const routeKeys = filters.routeKeys;
|
|
85
159
|
if (routeKeys) {
|
|
86
160
|
q = q.filter((doc) => interface_database_1.ValueProxy.constant(routeKeys).includes(doc
|
|
87
|
-
.key("
|
|
161
|
+
.key("routeMethod")
|
|
162
|
+
.default(doc.key("method"))
|
|
88
163
|
.cast()
|
|
89
|
-
.upcase()
|
|
90
164
|
.concat(":")
|
|
91
165
|
.concat(doc.key("uri"))));
|
|
92
166
|
}
|
|
93
167
|
return q;
|
|
94
168
|
}
|
|
169
|
+
applySearch(q, filters) {
|
|
170
|
+
if (!filters.search)
|
|
171
|
+
return q;
|
|
172
|
+
const prefix = (0, request_log_search_1.requestIdPrefix)(filters.search);
|
|
173
|
+
if (prefix) {
|
|
174
|
+
return q.filter((doc) => doc
|
|
175
|
+
.key("_id")
|
|
176
|
+
.ge(prefix)
|
|
177
|
+
.and(doc.key("_id").lt(`${prefix}${request_log_search_1.ID_PREFIX_END}`)));
|
|
178
|
+
}
|
|
179
|
+
const pattern = (0, request_log_search_1.searchPattern)(filters.search);
|
|
180
|
+
return q.filter((doc) => doc
|
|
181
|
+
.key("rawPath")
|
|
182
|
+
.match(pattern)
|
|
183
|
+
.or(doc
|
|
184
|
+
.key("error")
|
|
185
|
+
.default(null)
|
|
186
|
+
.key("message")
|
|
187
|
+
.default("")
|
|
188
|
+
.match(pattern)));
|
|
189
|
+
}
|
|
95
190
|
applyStatusFilters(q, filters) {
|
|
96
191
|
if (filters.statusClass) {
|
|
97
|
-
const { min, max } = STATUS_CLASS_RANGES[filters.statusClass];
|
|
192
|
+
const { min, max } = request_log_status_1.STATUS_CLASS_RANGES[filters.statusClass];
|
|
98
193
|
q = q.filter((doc) => {
|
|
99
194
|
const lower = doc.key("statusCode").ge(min);
|
|
100
195
|
return max === undefined
|