@antelopejs/dms-api 0.0.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/LICENSE +190 -0
- package/README.md +61 -0
- package/dist/automation/get-api-health.d.ts +10 -0
- package/dist/automation/get-api-health.js +53 -0
- package/dist/automation/get-api-health.js.map +1 -0
- package/dist/automation/index.d.ts +2 -0
- package/dist/automation/index.js +19 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/query-request-logs.d.ts +18 -0
- package/dist/automation/query-request-logs.js +50 -0
- package/dist/automation/query-request-logs.js.map +1 -0
- package/dist/automation/route-unhealthy.d.ts +9 -0
- package/dist/automation/route-unhealthy.js +102 -0
- package/dist/automation/route-unhealthy.js.map +1 -0
- package/dist/automation/scope.d.ts +2 -0
- package/dist/automation/scope.js +18 -0
- package/dist/automation/scope.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +19 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/models/api_settings.model.d.ts +23 -0
- package/dist/db/models/api_settings.model.js +13 -0
- package/dist/db/models/api_settings.model.js.map +1 -0
- package/dist/db/models/index.d.ts +4 -0
- package/dist/db/models/index.js +21 -0
- package/dist/db/models/index.js.map +1 -0
- package/dist/db/models/request_log.model.d.ts +47 -0
- package/dist/db/models/request_log.model.js +127 -0
- package/dist/db/models/request_log.model.js.map +1 -0
- package/dist/db/models/routes.model.d.ts +22 -0
- package/dist/db/models/routes.model.js +9 -0
- package/dist/db/models/routes.model.js.map +1 -0
- package/dist/db/models/routes_statistics.model.d.ts +23 -0
- package/dist/db/models/routes_statistics.model.js +13 -0
- package/dist/db/models/routes_statistics.model.js.map +1 -0
- package/dist/db/tables/api_settings.table.d.ts +10 -0
- package/dist/db/tables/api_settings.table.js +47 -0
- package/dist/db/tables/api_settings.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +4 -0
- package/dist/db/tables/index.js +21 -0
- package/dist/db/tables/index.js.map +1 -0
- package/dist/db/tables/request_log.table.d.ts +29 -0
- package/dist/db/tables/request_log.table.js +107 -0
- package/dist/db/tables/request_log.table.js.map +1 -0
- package/dist/db/tables/routes.table.d.ts +11 -0
- package/dist/db/tables/routes.table.js +50 -0
- package/dist/db/tables/routes.table.js.map +1 -0
- package/dist/db/tables/routes_statistics.table.d.ts +9 -0
- package/dist/db/tables/routes_statistics.table.js +38 -0
- package/dist/db/tables/routes_statistics.table.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +18 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/request-log-capture.d.ts +1 -0
- package/dist/middlewares/request-log-capture.js +6 -0
- package/dist/middlewares/request-log-capture.js.map +1 -0
- package/dist/pages/all.d.ts +4 -0
- package/dist/pages/all.js +21 -0
- package/dist/pages/all.js.map +1 -0
- package/dist/pages/index.d.ts +4 -0
- package/dist/pages/index.js +21 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/logs/page.d.ts +9 -0
- package/dist/pages/logs/page.js +29 -0
- package/dist/pages/logs/page.js.map +1 -0
- package/dist/pages/module.d.ts +1 -0
- package/dist/pages/module.js +12 -0
- package/dist/pages/module.js.map +1 -0
- package/dist/pages/routes/page.d.ts +9 -0
- package/dist/pages/routes/page.js +29 -0
- package/dist/pages/routes/page.js.map +1 -0
- package/dist/pages/settings/form.d.ts +3 -0
- package/dist/pages/settings/form.js +80 -0
- package/dist/pages/settings/form.js.map +1 -0
- package/dist/pages/settings/page.d.ts +9 -0
- package/dist/pages/settings/page.js +26 -0
- package/dist/pages/settings/page.js.map +1 -0
- package/dist/pages/summary/page.d.ts +9 -0
- package/dist/pages/summary/page.js +29 -0
- package/dist/pages/summary/page.js.map +1 -0
- package/dist/routes/index.d.ts +5 -0
- package/dist/routes/index.js +22 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/logs.d.ts +7 -0
- package/dist/routes/logs.js +128 -0
- package/dist/routes/logs.js.map +1 -0
- package/dist/routes/monitoring.d.ts +17 -0
- package/dist/routes/monitoring.js +101 -0
- package/dist/routes/monitoring.js.map +1 -0
- package/dist/routes/routes.d.ts +37 -0
- package/dist/routes/routes.js +153 -0
- package/dist/routes/routes.js.map +1 -0
- package/dist/routes/settings.d.ts +24 -0
- package/dist/routes/settings.js +92 -0
- package/dist/routes/settings.js.map +1 -0
- package/dist/routes/summary.d.ts +32 -0
- package/dist/routes/summary.js +181 -0
- package/dist/routes/summary.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +28 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/introspection/auth.d.ts +4 -0
- package/dist/services/introspection/auth.js +33 -0
- package/dist/services/introspection/auth.js.map +1 -0
- package/dist/services/introspection/errors.d.ts +6 -0
- package/dist/services/introspection/errors.js +50 -0
- package/dist/services/introspection/errors.js.map +1 -0
- package/dist/services/introspection/index.d.ts +53 -0
- package/dist/services/introspection/index.js +141 -0
- package/dist/services/introspection/index.js.map +1 -0
- package/dist/services/introspection/probe.d.ts +18 -0
- package/dist/services/introspection/probe.js +155 -0
- package/dist/services/introspection/probe.js.map +1 -0
- package/dist/services/period.d.ts +11 -0
- package/dist/services/period.js +68 -0
- package/dist/services/period.js.map +1 -0
- package/dist/services/request-log/capture.d.ts +10 -0
- package/dist/services/request-log/capture.js +189 -0
- package/dist/services/request-log/capture.js.map +1 -0
- package/dist/services/request-log/index.d.ts +3 -0
- package/dist/services/request-log/index.js +12 -0
- package/dist/services/request-log/index.js.map +1 -0
- package/dist/services/request-log/prune.d.ts +2 -0
- package/dist/services/request-log/prune.js +10 -0
- package/dist/services/request-log/prune.js.map +1 -0
- package/dist/services/request-log/read.d.ts +6 -0
- package/dist/services/request-log/read.js +26 -0
- package/dist/services/request-log/read.js.map +1 -0
- package/dist/services/request-log/redaction.d.ts +4 -0
- package/dist/services/request-log/redaction.js +53 -0
- package/dist/services/request-log/redaction.js.map +1 -0
- package/dist/services/request-log/util.d.ts +13 -0
- package/dist/services/request-log/util.js +114 -0
- package/dist/services/request-log/util.js.map +1 -0
- package/dist/services/routes-sync.d.ts +5 -0
- package/dist/services/routes-sync.js +63 -0
- package/dist/services/routes-sync.js.map +1 -0
- package/dist/services/scope.d.ts +7 -0
- package/dist/services/scope.js +40 -0
- package/dist/services/scope.js.map +1 -0
- package/dist/services/settings.d.ts +20 -0
- package/dist/services/settings.js +86 -0
- package/dist/services/settings.js.map +1 -0
- package/dist/services/statistics-aggregate.d.ts +67 -0
- package/dist/services/statistics-aggregate.js +340 -0
- package/dist/services/statistics-aggregate.js.map +1 -0
- package/dist/services/statistics-prune.d.ts +2 -0
- package/dist/services/statistics-prune.js +25 -0
- package/dist/services/statistics-prune.js.map +1 -0
- package/dist/services/statistics-read.d.ts +4 -0
- package/dist/services/statistics-read.js +48 -0
- package/dist/services/statistics-read.js.map +1 -0
- package/dist/services/statistics-utils.d.ts +14 -0
- package/dist/services/statistics-utils.js +65 -0
- package/dist/services/statistics-utils.js.map +1 -0
- package/dist/services/statistics-write.d.ts +3 -0
- package/dist/services/statistics-write.js +84 -0
- package/dist/services/statistics-write.js.map +1 -0
- package/dist/services/tree.d.ts +10 -0
- package/dist/services/tree.js +128 -0
- package/dist/services/tree.js.map +1 -0
- package/dist/types/charts.d.ts +9 -0
- package/dist/types/charts.js +3 -0
- package/dist/types/charts.js.map +1 -0
- package/dist/types/constants.d.ts +31 -0
- package/dist/types/constants.js +49 -0
- package/dist/types/constants.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/statistics.d.ts +17 -0
- package/dist/types/statistics.js +3 -0
- package/dist/types/statistics.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +12 -0
- package/frontend-vue/.vscode/settings.json +26 -0
- package/frontend-vue/app/components/ConfigurationView.vue +187 -0
- package/frontend-vue/app/components/DocumentationView.vue +224 -0
- package/frontend-vue/app/components/LogDetailDrawer.vue +178 -0
- package/frontend-vue/app/components/LogsView.vue +347 -0
- package/frontend-vue/app/components/RouteDetailTabs.vue +179 -0
- package/frontend-vue/app/components/RouteTree.vue +196 -0
- package/frontend-vue/app/components/RoutesView.vue +82 -0
- package/frontend-vue/app/components/StatsView.vue +268 -0
- package/frontend-vue/app/components/SummaryView.vue +657 -0
- package/frontend-vue/app/components/TesterPanel.vue +499 -0
- package/frontend-vue/app/components/internal/ApiMethodBadge.vue +33 -0
- package/frontend-vue/app/components/internal/ApiStatusBadge.vue +28 -0
- package/frontend-vue/app/components/internal/PeriodSelect.vue +58 -0
- package/frontend-vue/app/components/internal/RouteTreeNode.vue +168 -0
- package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +162 -0
- package/frontend-vue/app/components/internal/StatusDonut.vue +84 -0
- package/frontend-vue/app/components/internal/UnitAreaChart.vue +73 -0
- package/frontend-vue/app/composables/useApiIntrospection.ts +344 -0
- package/frontend-vue/app/composables/useLogDetailDrawer.ts +50 -0
- package/frontend-vue/app/composables/useSelectedPeriod.ts +107 -0
- package/frontend-vue/app/composables/useStatsPeriods.ts +139 -0
- 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 +49 -0
- package/frontend-vue/app/utils/statusClass.ts +49 -0
- package/frontend-vue/app/utils/testerRequest.ts +50 -0
- package/frontend-vue/dms.frontend.ts +25 -0
- package/frontend-vue/eslint.config.mjs +16 -0
- package/frontend-vue/i18n/locales/en-GB.json +240 -0
- package/frontend-vue/i18n/locales/fr-FR.json +240 -0
- package/frontend-vue/package.json +35 -0
- package/frontend-vue/pnpm-lock.yaml +5796 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/public/.gitkeep +0 -0
- package/frontend-vue/server/.gitkeep +0 -0
- package/frontend-vue/tests/periods.test.ts +145 -0
- package/frontend-vue/tests/persistence.test.ts +45 -0
- package/frontend-vue/tests/registration.test.ts +28 -0
- package/frontend-vue/tests/testerRequest.test.ts +95 -0
- package/frontend-vue/tsconfig.json +13 -0
- package/frontend-vue/vitest.config.ts +8 -0
- package/package.json +67 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LogsController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
18
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
19
|
+
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
20
|
+
const config_1 = require("@/config");
|
|
21
|
+
const db_1 = require("@/db");
|
|
22
|
+
const read_1 = require("@/services/request-log/read");
|
|
23
|
+
const scope_1 = require("@/services/scope");
|
|
24
|
+
const settings_1 = require("@/services/settings");
|
|
25
|
+
const types_1 = require("@/types");
|
|
26
|
+
const TAB_FILTERS = {
|
|
27
|
+
requests: {},
|
|
28
|
+
errors: { statusClass: "server-error" },
|
|
29
|
+
slow: {},
|
|
30
|
+
};
|
|
31
|
+
const STATUS_CLASSES = new Set([
|
|
32
|
+
"success",
|
|
33
|
+
"client-error",
|
|
34
|
+
"server-error",
|
|
35
|
+
]);
|
|
36
|
+
const PERIOD_UNIT_MS = {
|
|
37
|
+
s: types_1.MS_PER_SECOND,
|
|
38
|
+
m: types_1.MS_PER_MINUTE,
|
|
39
|
+
h: types_1.MS_PER_HOUR,
|
|
40
|
+
d: types_1.MS_PER_DAY,
|
|
41
|
+
};
|
|
42
|
+
let LogsController = class LogsController extends (0, interface_api_1.Controller)("/api/monitoring/logs") {
|
|
43
|
+
async listLogs(_user, tab, period, method, status, search, cursor, limit) {
|
|
44
|
+
const filters = buildLogFilters({ tab, period, method, status, search, cursor, limit }, (0, config_1.getConfig)().requestSlownessThreshold);
|
|
45
|
+
const keys = await (0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)());
|
|
46
|
+
return (0, read_1.queryRequestLogsScoped)((0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), filters, keys);
|
|
47
|
+
}
|
|
48
|
+
async getLog(_user, id) {
|
|
49
|
+
const log = await (0, read_1.getRequestLog)((0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), id);
|
|
50
|
+
(0, interface_api_util_1.assert)(log, 404, "Log not found");
|
|
51
|
+
return log;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.LogsController = LogsController;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, interface_api_1.Get)(""),
|
|
57
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
58
|
+
__param(1, (0, interface_api_1.Parameter)("tab", "query")),
|
|
59
|
+
__param(2, (0, interface_api_1.Parameter)("period", "query")),
|
|
60
|
+
__param(3, (0, interface_api_1.Parameter)("method", "query")),
|
|
61
|
+
__param(4, (0, interface_api_1.Parameter)("status", "query")),
|
|
62
|
+
__param(5, (0, interface_api_1.Parameter)("search", "query")),
|
|
63
|
+
__param(6, (0, interface_api_1.Parameter)("cursor", "query")),
|
|
64
|
+
__param(7, (0, interface_api_1.Parameter)("limit", "query")),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [Function, String, String, String, String, String, String, String]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], LogsController.prototype, "listLogs", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, interface_api_1.Get)(":id"),
|
|
71
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
72
|
+
__param(1, (0, interface_api_1.Parameter)("id", "param")),
|
|
73
|
+
__metadata("design:type", Function),
|
|
74
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
75
|
+
__metadata("design:returntype", Promise)
|
|
76
|
+
], LogsController.prototype, "getLog", null);
|
|
77
|
+
exports.LogsController = LogsController = __decorate([
|
|
78
|
+
(0, auth_1.AuthOwnerOnly)()
|
|
79
|
+
], LogsController);
|
|
80
|
+
function buildLogFilters(params, slowThresholdMs) {
|
|
81
|
+
const resolvedTab = params.tab in TAB_FILTERS ? params.tab : "requests";
|
|
82
|
+
const filters = {
|
|
83
|
+
...TAB_FILTERS[resolvedTab],
|
|
84
|
+
method: params.method,
|
|
85
|
+
search: params.search,
|
|
86
|
+
cursor: params.cursor,
|
|
87
|
+
limit: parseLimit(params.limit),
|
|
88
|
+
};
|
|
89
|
+
if (params.status) {
|
|
90
|
+
if (STATUS_CLASSES.has(params.status)) {
|
|
91
|
+
filters.statusClass = params.status;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const n = parseInt(params.status, 10);
|
|
95
|
+
if (!Number.isNaN(n)) {
|
|
96
|
+
filters.statusMin = n;
|
|
97
|
+
filters.statusMax = n;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (params.period) {
|
|
102
|
+
const ms = periodToMs(params.period);
|
|
103
|
+
if (ms !== undefined)
|
|
104
|
+
filters.since = new Date(Date.now() - ms);
|
|
105
|
+
}
|
|
106
|
+
if (resolvedTab === "slow") {
|
|
107
|
+
filters.slowThresholdMs = slowThresholdMs;
|
|
108
|
+
}
|
|
109
|
+
return filters;
|
|
110
|
+
}
|
|
111
|
+
function parseLimit(raw) {
|
|
112
|
+
if (!raw)
|
|
113
|
+
return undefined;
|
|
114
|
+
const n = parseInt(raw, 10);
|
|
115
|
+
if (Number.isNaN(n) || n <= 0)
|
|
116
|
+
return undefined;
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
function periodToMs(period) {
|
|
120
|
+
const m = period.match(/^(\d+)([smhd])$/);
|
|
121
|
+
if (!m)
|
|
122
|
+
return undefined;
|
|
123
|
+
const n = parseInt(m[1], 10);
|
|
124
|
+
if (n <= 0)
|
|
125
|
+
return undefined;
|
|
126
|
+
return n * PERIOD_UNIT_MS[m[2]];
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/routes/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuE;AACvE,uEAAwD;AACxD,6FAAqE;AACrE,yDAA4E;AAE5E,qCAAqC;AACrC,6BAAmD;AAKnD,sDAGqC;AACrC,4CAAsD;AACtD,kDAAqD;AACrD,mCAAgF;AAIhF,MAAM,WAAW,GAA+C;IAC9D,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;IACvC,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,SAAS;IACT,cAAc;IACd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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
2
|
+
import { type HistoryPoint, type RouteAggregate } from "@/services/statistics-aggregate";
|
|
3
|
+
declare const MonitoringController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
4
|
+
export declare class MonitoringController extends MonitoringController_base {
|
|
5
|
+
getMonitoring(_user: User, period?: string, route?: string): Promise<{
|
|
6
|
+
period: {
|
|
7
|
+
granularity: "day" | "hour" | "minute";
|
|
8
|
+
count: number;
|
|
9
|
+
};
|
|
10
|
+
kpis: import("@/services/statistics-aggregate").SummaryKpis;
|
|
11
|
+
history: HistoryPoint[];
|
|
12
|
+
slowest: RouteAggregate[];
|
|
13
|
+
mostErroring: RouteAggregate[];
|
|
14
|
+
recent: import("@/db").RequestLog[];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MonitoringController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
18
|
+
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
19
|
+
const db_1 = require("@/db");
|
|
20
|
+
const period_1 = require("@/services/period");
|
|
21
|
+
const read_1 = require("@/services/request-log/read");
|
|
22
|
+
const scope_1 = require("@/services/scope");
|
|
23
|
+
const settings_1 = require("@/services/settings");
|
|
24
|
+
const statistics_aggregate_1 = require("@/services/statistics-aggregate");
|
|
25
|
+
const DEFAULT_DAYS = 7;
|
|
26
|
+
const SLOW_ROUTES_LIMIT = 5;
|
|
27
|
+
const ERROR_ROUTES_LIMIT = 5;
|
|
28
|
+
const RECENT_REQUESTS_LIMIT = 10;
|
|
29
|
+
let MonitoringController = class MonitoringController extends (0, interface_api_1.Controller)("/api/monitoring/metrics") {
|
|
30
|
+
async getMonitoring(_user, period, route) {
|
|
31
|
+
const parsed = resolvePeriod(period);
|
|
32
|
+
const aggregateDays = parsed.granularity === "day" ? parsed.count : 1;
|
|
33
|
+
const routesModel = (0, interface_database_decorators_1.GetModel)(db_1.RouteModel);
|
|
34
|
+
const statsModel = (0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel);
|
|
35
|
+
const logModel = (0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel);
|
|
36
|
+
const keys = await (0, scope_1.getScopedRouteKeys)(routesModel, (0, settings_1.getActiveScope)());
|
|
37
|
+
const [routes, history, aggregates, recentPage] = await Promise.all([
|
|
38
|
+
routesModel.getAll(),
|
|
39
|
+
loadHistory(parsed, logModel, statsModel, keys),
|
|
40
|
+
(0, statistics_aggregate_1.getRouteAggregates)(statsModel, aggregateDays, keys),
|
|
41
|
+
(0, read_1.queryRequestLogsScoped)(logModel, { limit: RECENT_REQUESTS_LIMIT }, keys),
|
|
42
|
+
]);
|
|
43
|
+
const filtered = route
|
|
44
|
+
? aggregates.filter((a) => a.uri === route)
|
|
45
|
+
: aggregates;
|
|
46
|
+
const totalRoutes = keys ? keys.size : routes.length;
|
|
47
|
+
const kpis = await (0, statistics_aggregate_1.getSummaryKpis)(statsModel, totalRoutes, keys);
|
|
48
|
+
return {
|
|
49
|
+
period: {
|
|
50
|
+
granularity: parsed.granularity,
|
|
51
|
+
count: parsed.count,
|
|
52
|
+
},
|
|
53
|
+
kpis,
|
|
54
|
+
history,
|
|
55
|
+
slowest: rankSlowest(filtered),
|
|
56
|
+
mostErroring: rankMostErroring(filtered),
|
|
57
|
+
recent: recentPage.results,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.MonitoringController = MonitoringController;
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, interface_api_1.Get)(""),
|
|
64
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
65
|
+
__param(1, (0, interface_api_1.Parameter)("period", "query")),
|
|
66
|
+
__param(2, (0, interface_api_1.Parameter)("route", "query")),
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", [Function, String, String]),
|
|
69
|
+
__metadata("design:returntype", Promise)
|
|
70
|
+
], MonitoringController.prototype, "getMonitoring", null);
|
|
71
|
+
exports.MonitoringController = MonitoringController = __decorate([
|
|
72
|
+
(0, auth_1.AuthOwnerOnly)()
|
|
73
|
+
], MonitoringController);
|
|
74
|
+
function resolvePeriod(period) {
|
|
75
|
+
return ((0, period_1.parsePeriod)(period) ?? {
|
|
76
|
+
granularity: "day",
|
|
77
|
+
count: (0, period_1.resolvePeriodDays)(undefined, DEFAULT_DAYS),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function loadHistory(parsed, logModel, statsModel, keys) {
|
|
81
|
+
const byGranularity = {
|
|
82
|
+
minute: () => (0, statistics_aggregate_1.getRequestHistoryMinutely)(logModel, parsed.count, keys),
|
|
83
|
+
hour: () => (0, statistics_aggregate_1.getRequestHistoryHourly)(logModel, parsed.count, keys),
|
|
84
|
+
day: () => (0, statistics_aggregate_1.getRequestHistory)(statsModel, parsed.count, keys),
|
|
85
|
+
};
|
|
86
|
+
return byGranularity[parsed.granularity]();
|
|
87
|
+
}
|
|
88
|
+
function rankSlowest(aggregates) {
|
|
89
|
+
return aggregates
|
|
90
|
+
.slice()
|
|
91
|
+
.sort((a, b) => b.averageLatencyMs - a.averageLatencyMs)
|
|
92
|
+
.slice(0, SLOW_ROUTES_LIMIT);
|
|
93
|
+
}
|
|
94
|
+
function rankMostErroring(aggregates) {
|
|
95
|
+
return aggregates
|
|
96
|
+
.slice()
|
|
97
|
+
.filter((a) => a.errorsClient + a.errorsServer > 0)
|
|
98
|
+
.sort((a, b) => b.errorsClient + b.errorsServer - (a.errorsClient + a.errorsServer))
|
|
99
|
+
.slice(0, ERROR_ROUTES_LIMIT);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=monitoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoring.js","sourceRoot":"","sources":["../../src/routes/monitoring.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuE;AACvE,6FAAqE;AACrE,yDAA4E;AAE5E,6BAAyE;AACzE,8CAI2B;AAC3B,sDAAqE;AACrE,4CAAsD;AACtD,kDAAqD;AACrD,0EAQyC;AAEzC,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAG1B,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,IAAA,0BAAU,EAClD,yBAAyB,CAC1B;IAEO,AAAN,KAAK,CAAC,aAAa,CACF,KAAW,EACI,MAAe,EAChB,KAAc;QAE3C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,aAAa,GAAG,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KAAK,EAAE;SACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC;SACvD,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA4B;IACpD,OAAO,UAAU;SACd,KAAK,EAAE;SACP,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC;SAClD,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC,CACtE;SACA,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
2
|
+
declare const RoutesController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
3
|
+
export declare class RoutesController extends RoutesController_base {
|
|
4
|
+
getTree(_user: User, period?: string): Promise<import("@antelopejs/interface-dms/dist/base").TreeNode[]>;
|
|
5
|
+
getRouteDoc(_user: User, id: string): Promise<{
|
|
6
|
+
registeredAt: Date | null;
|
|
7
|
+
updatedAt: Date | null;
|
|
8
|
+
id: string;
|
|
9
|
+
location: string;
|
|
10
|
+
method: string;
|
|
11
|
+
mode: import("@antelopejs/interface-api").RouteHandlerMode;
|
|
12
|
+
callbackName: string;
|
|
13
|
+
priority?: number;
|
|
14
|
+
parameters: import("@/services/introspection").ParameterInfo[];
|
|
15
|
+
properties: import("@/services/introspection").PropertyInfo[];
|
|
16
|
+
applicableMiddleware: import("@/services/introspection").MiddlewareInfo[];
|
|
17
|
+
errorCodes: import("@/services/introspection").InferredErrorCode[];
|
|
18
|
+
}>;
|
|
19
|
+
getRouteConfig(_user: User, id: string): Promise<import("@/services/introspection").RouteInspection>;
|
|
20
|
+
getRouteStats(_user: User, id: string, period?: string): Promise<{
|
|
21
|
+
route: {
|
|
22
|
+
id: string;
|
|
23
|
+
location: string;
|
|
24
|
+
method: string;
|
|
25
|
+
};
|
|
26
|
+
aggregate: import("@/services/statistics-aggregate").RouteAggregate | undefined;
|
|
27
|
+
charts: {
|
|
28
|
+
counts: import("../types").ChartResponse;
|
|
29
|
+
latency: import("../types").ChartResponse;
|
|
30
|
+
};
|
|
31
|
+
recent: import("@/db").RequestLog[];
|
|
32
|
+
}>;
|
|
33
|
+
getFolderDoc(_user: User, encodedPath: string): Promise<import("@/services/introspection").FolderInspection>;
|
|
34
|
+
getFolderConfig(_user: User, encodedPath: string): Promise<import("@/services/introspection").FolderInspection>;
|
|
35
|
+
getFolderStats(_user: User, encodedPath: string, period?: string): Promise<import("@/services/statistics-aggregate").FolderAggregate>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RoutesController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
18
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
19
|
+
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
20
|
+
const db_1 = require("@/db");
|
|
21
|
+
const introspection_1 = require("@/services/introspection");
|
|
22
|
+
const period_1 = require("@/services/period");
|
|
23
|
+
const read_1 = require("@/services/request-log/read");
|
|
24
|
+
const scope_1 = require("@/services/scope");
|
|
25
|
+
const settings_1 = require("@/services/settings");
|
|
26
|
+
const statistics_aggregate_1 = require("@/services/statistics-aggregate");
|
|
27
|
+
const statistics_read_1 = require("@/services/statistics-read");
|
|
28
|
+
const tree_1 = require("@/services/tree");
|
|
29
|
+
const DEFAULT_STATS_DAYS = 7;
|
|
30
|
+
const RECENT_LOGS_DEFAULT = 20;
|
|
31
|
+
let RoutesController = class RoutesController extends (0, interface_api_1.Controller)("/api/monitoring/routes") {
|
|
32
|
+
async getTree(_user, period) {
|
|
33
|
+
const [stats, keys] = await Promise.all([
|
|
34
|
+
(0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel).getAll(),
|
|
35
|
+
(0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)()),
|
|
36
|
+
]);
|
|
37
|
+
return (0, tree_1.buildRoutesTreeNodes)(stats, keys, (0, period_1.parsePeriodDays)(period));
|
|
38
|
+
}
|
|
39
|
+
async getRouteDoc(_user, id) {
|
|
40
|
+
const inspection = (0, introspection_1.getRouteInspection)(id);
|
|
41
|
+
(0, interface_api_util_1.assert)(inspection, 404, "Route not found");
|
|
42
|
+
const route = await (0, interface_database_decorators_1.GetModel)(db_1.RouteModel).get(id);
|
|
43
|
+
return {
|
|
44
|
+
...inspection,
|
|
45
|
+
registeredAt: route?.createdAt ?? null,
|
|
46
|
+
updatedAt: route?.updatedAt ?? null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async getRouteConfig(_user, id) {
|
|
50
|
+
const inspection = (0, introspection_1.getRouteInspection)(id);
|
|
51
|
+
(0, interface_api_util_1.assert)(inspection, 404, "Route not found");
|
|
52
|
+
return inspection;
|
|
53
|
+
}
|
|
54
|
+
async getRouteStats(_user, id, period) {
|
|
55
|
+
const inspection = (0, introspection_1.getRouteInspection)(id);
|
|
56
|
+
(0, interface_api_util_1.assert)(inspection, 404, "Route not found");
|
|
57
|
+
const days = (0, period_1.resolvePeriodDays)(period, DEFAULT_STATS_DAYS);
|
|
58
|
+
const stats = (0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel);
|
|
59
|
+
const log = (0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel);
|
|
60
|
+
const [counts, latency, aggregate, recent] = await Promise.all([
|
|
61
|
+
(0, statistics_read_1.getRouteStatistics)(stats, inspection.method, inspection.location, days),
|
|
62
|
+
(0, statistics_read_1.getResponseTimesStatistics)(stats, inspection.method, inspection.location, days),
|
|
63
|
+
(0, statistics_aggregate_1.getRouteAggregate)(stats, inspection.method, inspection.location, days),
|
|
64
|
+
(0, read_1.getRecentLogsForRoute)(log, id, RECENT_LOGS_DEFAULT),
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
route: {
|
|
68
|
+
id,
|
|
69
|
+
location: inspection.location,
|
|
70
|
+
method: inspection.method,
|
|
71
|
+
},
|
|
72
|
+
aggregate,
|
|
73
|
+
charts: { counts, latency },
|
|
74
|
+
recent,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async getFolderDoc(_user, encodedPath) {
|
|
78
|
+
return (0, introspection_1.getFolderInspection)(decodePath(encodedPath));
|
|
79
|
+
}
|
|
80
|
+
async getFolderConfig(_user, encodedPath) {
|
|
81
|
+
return (0, introspection_1.getFolderInspection)(decodePath(encodedPath));
|
|
82
|
+
}
|
|
83
|
+
async getFolderStats(_user, encodedPath, period) {
|
|
84
|
+
const days = (0, period_1.resolvePeriodDays)(period, DEFAULT_STATS_DAYS);
|
|
85
|
+
return (0, statistics_aggregate_1.getFolderAggregate)((0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel), decodePath(encodedPath), days);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.RoutesController = RoutesController;
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, interface_api_1.Get)("tree"),
|
|
91
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
92
|
+
__param(1, (0, interface_api_1.Parameter)("period", "query")),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], RoutesController.prototype, "getTree", null);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, interface_api_1.Get)("route/:id/doc"),
|
|
99
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
100
|
+
__param(1, (0, interface_api_1.Parameter)("id", "param")),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], RoutesController.prototype, "getRouteDoc", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, interface_api_1.Get)("route/:id/config"),
|
|
107
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
108
|
+
__param(1, (0, interface_api_1.Parameter)("id", "param")),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
111
|
+
__metadata("design:returntype", Promise)
|
|
112
|
+
], RoutesController.prototype, "getRouteConfig", null);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, interface_api_1.Get)("route/:id/stats"),
|
|
115
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
116
|
+
__param(1, (0, interface_api_1.Parameter)("id", "param")),
|
|
117
|
+
__param(2, (0, interface_api_1.Parameter)("period", "query")),
|
|
118
|
+
__metadata("design:type", Function),
|
|
119
|
+
__metadata("design:paramtypes", [Function, String, String]),
|
|
120
|
+
__metadata("design:returntype", Promise)
|
|
121
|
+
], RoutesController.prototype, "getRouteStats", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, interface_api_1.Get)("folder/:encodedPath/doc"),
|
|
124
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
125
|
+
__param(1, (0, interface_api_1.Parameter)("encodedPath", "param")),
|
|
126
|
+
__metadata("design:type", Function),
|
|
127
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
128
|
+
__metadata("design:returntype", Promise)
|
|
129
|
+
], RoutesController.prototype, "getFolderDoc", null);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, interface_api_1.Get)("folder/:encodedPath/config"),
|
|
132
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
133
|
+
__param(1, (0, interface_api_1.Parameter)("encodedPath", "param")),
|
|
134
|
+
__metadata("design:type", Function),
|
|
135
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
136
|
+
__metadata("design:returntype", Promise)
|
|
137
|
+
], RoutesController.prototype, "getFolderConfig", null);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, interface_api_1.Get)("folder/:encodedPath/stats"),
|
|
140
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
141
|
+
__param(1, (0, interface_api_1.Parameter)("encodedPath", "param")),
|
|
142
|
+
__param(2, (0, interface_api_1.Parameter)("period", "query")),
|
|
143
|
+
__metadata("design:type", Function),
|
|
144
|
+
__metadata("design:paramtypes", [Function, String, String]),
|
|
145
|
+
__metadata("design:returntype", Promise)
|
|
146
|
+
], RoutesController.prototype, "getFolderStats", null);
|
|
147
|
+
exports.RoutesController = RoutesController = __decorate([
|
|
148
|
+
(0, auth_1.AuthOwnerOnly)()
|
|
149
|
+
], RoutesController);
|
|
150
|
+
function decodePath(encoded) {
|
|
151
|
+
return `/${decodeURIComponent(encoded).split("/").filter(Boolean).join("/")}`;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes/routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuE;AACvE,uEAAwD;AACxD,6FAAqE;AACrE,yDAA4E;AAE5E,6BAAyE;AACzE,4DAGkC;AAClC,8CAAuE;AACvE,sDAAoE;AACpE,4CAAsD;AACtD,kDAAqD;AACrD,0EAGyC;AACzC,gEAGoC;AACpC,0CAAuD;AAEvD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAQxB,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,0BAAU,EAAC,wBAAwB,CAAC;IAElE,AAAN,KAAK,CAAC,OAAO,CACI,KAAW,EACI,MAAe;QAE7C,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACtC,IAAA,wCAAQ,EAAC,yBAAoB,CAAC,CAAC,MAAM,EAAE;YACvC,IAAA,0BAAkB,EAAC,IAAA,wCAAQ,EAAC,eAAU,CAAC,EAAE,IAAA,yBAAc,GAAE,CAAC;SAC3D,CAAC,CAAC;QACH,OAAO,IAAA,2BAAoB,EAAC,KAAK,EAAE,IAAI,EAAE,IAAA,wBAAe,EAAC,MAAM,CAAC,CAAC,CAAC;IACpE,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CACA,KAAW,EACA,EAAU;QAEpC,MAAM,UAAU,GAAG,IAAA,kCAAkB,EAAC,EAAE,CAAC,CAAC;QAC1C,IAAA,2BAAM,EAAC,UAAU,EAAE,GAAG,EAAE,iB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/auth/db";
|
|
2
|
+
import type { RouteScope } from "@/services/scope";
|
|
3
|
+
declare const SettingsController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
4
|
+
export declare class SettingsController extends SettingsController_base {
|
|
5
|
+
getSettings(_user: User): Promise<{
|
|
6
|
+
scope: RouteScope;
|
|
7
|
+
requestLogRetentionDays: number;
|
|
8
|
+
statisticsLifetimeDays: number;
|
|
9
|
+
requestSlownessThresholdMs: number;
|
|
10
|
+
requestLogMaxBodyKb: number;
|
|
11
|
+
}>;
|
|
12
|
+
getRetention(_user: User): Promise<{
|
|
13
|
+
statisticsLifetimeDays: number;
|
|
14
|
+
requestLogRetentionDays: number;
|
|
15
|
+
}>;
|
|
16
|
+
submitSettings(_user: User, body: unknown): Promise<{
|
|
17
|
+
scope: RouteScope;
|
|
18
|
+
requestLogRetentionDays: number;
|
|
19
|
+
statisticsLifetimeDays: number;
|
|
20
|
+
requestSlownessThresholdMs: number;
|
|
21
|
+
requestLogMaxBodyKb: number;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SettingsController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
18
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
19
|
+
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
20
|
+
const db_1 = require("@/db");
|
|
21
|
+
const form_1 = require("@/pages/settings/form");
|
|
22
|
+
const period_1 = require("@/services/period");
|
|
23
|
+
const settings_1 = require("@/services/settings");
|
|
24
|
+
const types_1 = require("@/types");
|
|
25
|
+
const BYTES_PER_KB = 1024;
|
|
26
|
+
let SettingsController = class SettingsController extends (0, interface_api_1.Controller)("/api/monitoring/settings") {
|
|
27
|
+
async getSettings(_user) {
|
|
28
|
+
return formValues();
|
|
29
|
+
}
|
|
30
|
+
async getRetention(_user) {
|
|
31
|
+
return {
|
|
32
|
+
statisticsLifetimeDays: (0, period_1.getMaxStatsDays)(),
|
|
33
|
+
requestLogRetentionDays: (0, period_1.getMaxLogDays)(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async submitSettings(_user, body) {
|
|
37
|
+
const data = (0, interface_api_util_1.assertValidation)(body, (v) => form_1.apiSettingsFormSchema.parse(v));
|
|
38
|
+
await (0, settings_1.updateSettings)((0, interface_database_decorators_1.GetModel)(db_1.ApiSettingsModel), {
|
|
39
|
+
scope: data.scope,
|
|
40
|
+
requestLogRetention: fromUi(data.requestLogRetentionDays, types_1.MS_PER_DAY),
|
|
41
|
+
statisticsLifetime: fromUi(data.statisticsLifetimeDays, types_1.MS_PER_DAY),
|
|
42
|
+
requestSlownessThreshold: fromUi(data.requestSlownessThresholdMs, 1),
|
|
43
|
+
requestLogMaxBodySize: fromUi(data.requestLogMaxBodyKb, BYTES_PER_KB),
|
|
44
|
+
});
|
|
45
|
+
return formValues();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.SettingsController = SettingsController;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, interface_api_1.Get)(""),
|
|
51
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", [Function]),
|
|
54
|
+
__metadata("design:returntype", Promise)
|
|
55
|
+
], SettingsController.prototype, "getSettings", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, interface_api_1.Get)("retention"),
|
|
58
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
59
|
+
__metadata("design:type", Function),
|
|
60
|
+
__metadata("design:paramtypes", [Function]),
|
|
61
|
+
__metadata("design:returntype", Promise)
|
|
62
|
+
], SettingsController.prototype, "getRetention", null);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, interface_api_1.Post)(""),
|
|
65
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
66
|
+
__param(1, (0, interface_api_1.JSONBody)()),
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", [Function, Object]),
|
|
69
|
+
__metadata("design:returntype", Promise)
|
|
70
|
+
], SettingsController.prototype, "submitSettings", null);
|
|
71
|
+
exports.SettingsController = SettingsController = __decorate([
|
|
72
|
+
(0, auth_1.AuthOwnerOnly)()
|
|
73
|
+
], SettingsController);
|
|
74
|
+
function formValues() {
|
|
75
|
+
const s = (0, settings_1.getEffectiveSettings)();
|
|
76
|
+
return {
|
|
77
|
+
scope: s.scope,
|
|
78
|
+
requestLogRetentionDays: msToDays(s.requestLogRetention),
|
|
79
|
+
statisticsLifetimeDays: msToDays(s.statisticsLifetime),
|
|
80
|
+
requestSlownessThresholdMs: s.requestSlownessThreshold,
|
|
81
|
+
requestLogMaxBodyKb: Math.round(s.requestLogMaxBodySize / BYTES_PER_KB),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function msToDays(ms) {
|
|
85
|
+
return Math.max(1, Math.round(ms / types_1.MS_PER_DAY));
|
|
86
|
+
}
|
|
87
|
+
function fromUi(value, unit) {
|
|
88
|
+
if (typeof value !== "number" || Number.isNaN(value))
|
|
89
|
+
return null;
|
|
90
|
+
return Math.round(value * unit);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/routes/settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAA4E;AAC5E,uEAAkE;AAClE,6FAAqE;AACrE,yDAA4E;AAE5E,6BAAwC;AACxC,gDAA8D;AAC9D,8CAAmE;AAEnE,kDAA2E;AAC3E,mCAAqC;AAErC,MAAM,YAAY,GAAG,IAAI,CAAC;AAUnB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,0BAAU,EAAC,0BAA0B,CAAC;IAEtE,AAAN,KAAK,CAAC,WAAW,CAAgB,KAAW;QAC1C,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IAcK,AAAN,KAAK,CAAC,YAAY,CAAgB,KAAW;QAC3C,OAAO;YACL,sBAAsB,EAAE,IAAA,wBAAe,GAAE;YACzC,uBAAuB,EAAE,IAAA,sBAAa,GAAE;SACzC,CAAC;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,cAAc,CAAgB,KAAW,EAAc,IAAa;QACxE,MAAM,IAAI,GAAG,IAAA,qCAAgB,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,4BAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,IAAA,yBAAc,EAAC,IAAA,wCAAQ,EAAC,qBAAgB,CAAC,EAAE;YAC/C,KAAK,EAAE,IAAI,CAAC,KAAmB;YAC/B,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,uB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AAGD,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
2
|
+
declare const SummaryController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
3
|
+
export declare class SummaryController extends SummaryController_base {
|
|
4
|
+
getSummary(_user: User): Promise<{
|
|
5
|
+
kpis: import("@/services/statistics-aggregate").SummaryKpis;
|
|
6
|
+
autoGeneratedCount: number;
|
|
7
|
+
customCount: number;
|
|
8
|
+
}>;
|
|
9
|
+
getHealth(_user: User): Promise<{
|
|
10
|
+
status: "healthy" | "degraded" | "down";
|
|
11
|
+
errorRate: number;
|
|
12
|
+
averageLatencyMs: number;
|
|
13
|
+
uptime: null;
|
|
14
|
+
lastIncidentAt: Date;
|
|
15
|
+
}>;
|
|
16
|
+
getHistory(_user: User, period?: string): Promise<import("@/services/statistics-aggregate").HistoryPoint[]>;
|
|
17
|
+
getStatusBreakdown(_user: User, period?: string): Promise<import("@/services/statistics-aggregate").StatusBreakdown>;
|
|
18
|
+
getWatchList(_user: User, limit?: string): Promise<import("@/services/statistics-aggregate").WatchListItem[]>;
|
|
19
|
+
getActivity(_user: User): Promise<({
|
|
20
|
+
kind: "route-created";
|
|
21
|
+
timestamp: Date;
|
|
22
|
+
method: import("@/types").HttpMethod;
|
|
23
|
+
uri: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "error";
|
|
26
|
+
timestamp: Date;
|
|
27
|
+
method: import("@/types").HttpMethod;
|
|
28
|
+
uri: string;
|
|
29
|
+
statusCode: number;
|
|
30
|
+
})[]>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|