@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.
Files changed (224) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +61 -0
  3. package/dist/automation/get-api-health.d.ts +10 -0
  4. package/dist/automation/get-api-health.js +53 -0
  5. package/dist/automation/get-api-health.js.map +1 -0
  6. package/dist/automation/index.d.ts +2 -0
  7. package/dist/automation/index.js +19 -0
  8. package/dist/automation/index.js.map +1 -0
  9. package/dist/automation/query-request-logs.d.ts +18 -0
  10. package/dist/automation/query-request-logs.js +50 -0
  11. package/dist/automation/query-request-logs.js.map +1 -0
  12. package/dist/automation/route-unhealthy.d.ts +9 -0
  13. package/dist/automation/route-unhealthy.js +102 -0
  14. package/dist/automation/route-unhealthy.js.map +1 -0
  15. package/dist/automation/scope.d.ts +2 -0
  16. package/dist/automation/scope.js +18 -0
  17. package/dist/automation/scope.js.map +1 -0
  18. package/dist/config.d.ts +12 -0
  19. package/dist/config.js +38 -0
  20. package/dist/config.js.map +1 -0
  21. package/dist/db/index.d.ts +2 -0
  22. package/dist/db/index.js +19 -0
  23. package/dist/db/index.js.map +1 -0
  24. package/dist/db/models/api_settings.model.d.ts +23 -0
  25. package/dist/db/models/api_settings.model.js +13 -0
  26. package/dist/db/models/api_settings.model.js.map +1 -0
  27. package/dist/db/models/index.d.ts +4 -0
  28. package/dist/db/models/index.js +21 -0
  29. package/dist/db/models/index.js.map +1 -0
  30. package/dist/db/models/request_log.model.d.ts +47 -0
  31. package/dist/db/models/request_log.model.js +127 -0
  32. package/dist/db/models/request_log.model.js.map +1 -0
  33. package/dist/db/models/routes.model.d.ts +22 -0
  34. package/dist/db/models/routes.model.js +9 -0
  35. package/dist/db/models/routes.model.js.map +1 -0
  36. package/dist/db/models/routes_statistics.model.d.ts +23 -0
  37. package/dist/db/models/routes_statistics.model.js +13 -0
  38. package/dist/db/models/routes_statistics.model.js.map +1 -0
  39. package/dist/db/tables/api_settings.table.d.ts +10 -0
  40. package/dist/db/tables/api_settings.table.js +47 -0
  41. package/dist/db/tables/api_settings.table.js.map +1 -0
  42. package/dist/db/tables/index.d.ts +4 -0
  43. package/dist/db/tables/index.js +21 -0
  44. package/dist/db/tables/index.js.map +1 -0
  45. package/dist/db/tables/request_log.table.d.ts +29 -0
  46. package/dist/db/tables/request_log.table.js +107 -0
  47. package/dist/db/tables/request_log.table.js.map +1 -0
  48. package/dist/db/tables/routes.table.d.ts +11 -0
  49. package/dist/db/tables/routes.table.js +50 -0
  50. package/dist/db/tables/routes.table.js.map +1 -0
  51. package/dist/db/tables/routes_statistics.table.d.ts +9 -0
  52. package/dist/db/tables/routes_statistics.table.js +38 -0
  53. package/dist/db/tables/routes_statistics.table.js.map +1 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.js +56 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/middlewares/index.d.ts +1 -0
  58. package/dist/middlewares/index.js +18 -0
  59. package/dist/middlewares/index.js.map +1 -0
  60. package/dist/middlewares/request-log-capture.d.ts +1 -0
  61. package/dist/middlewares/request-log-capture.js +6 -0
  62. package/dist/middlewares/request-log-capture.js.map +1 -0
  63. package/dist/pages/all.d.ts +4 -0
  64. package/dist/pages/all.js +21 -0
  65. package/dist/pages/all.js.map +1 -0
  66. package/dist/pages/index.d.ts +4 -0
  67. package/dist/pages/index.js +21 -0
  68. package/dist/pages/index.js.map +1 -0
  69. package/dist/pages/logs/page.d.ts +9 -0
  70. package/dist/pages/logs/page.js +29 -0
  71. package/dist/pages/logs/page.js.map +1 -0
  72. package/dist/pages/module.d.ts +1 -0
  73. package/dist/pages/module.js +12 -0
  74. package/dist/pages/module.js.map +1 -0
  75. package/dist/pages/routes/page.d.ts +9 -0
  76. package/dist/pages/routes/page.js +29 -0
  77. package/dist/pages/routes/page.js.map +1 -0
  78. package/dist/pages/settings/form.d.ts +3 -0
  79. package/dist/pages/settings/form.js +80 -0
  80. package/dist/pages/settings/form.js.map +1 -0
  81. package/dist/pages/settings/page.d.ts +9 -0
  82. package/dist/pages/settings/page.js +26 -0
  83. package/dist/pages/settings/page.js.map +1 -0
  84. package/dist/pages/summary/page.d.ts +9 -0
  85. package/dist/pages/summary/page.js +29 -0
  86. package/dist/pages/summary/page.js.map +1 -0
  87. package/dist/routes/index.d.ts +5 -0
  88. package/dist/routes/index.js +22 -0
  89. package/dist/routes/index.js.map +1 -0
  90. package/dist/routes/logs.d.ts +7 -0
  91. package/dist/routes/logs.js +128 -0
  92. package/dist/routes/logs.js.map +1 -0
  93. package/dist/routes/monitoring.d.ts +17 -0
  94. package/dist/routes/monitoring.js +101 -0
  95. package/dist/routes/monitoring.js.map +1 -0
  96. package/dist/routes/routes.d.ts +37 -0
  97. package/dist/routes/routes.js +153 -0
  98. package/dist/routes/routes.js.map +1 -0
  99. package/dist/routes/settings.d.ts +24 -0
  100. package/dist/routes/settings.js +92 -0
  101. package/dist/routes/settings.js.map +1 -0
  102. package/dist/routes/summary.d.ts +32 -0
  103. package/dist/routes/summary.js +181 -0
  104. package/dist/routes/summary.js.map +1 -0
  105. package/dist/services/index.d.ts +11 -0
  106. package/dist/services/index.js +28 -0
  107. package/dist/services/index.js.map +1 -0
  108. package/dist/services/introspection/auth.d.ts +4 -0
  109. package/dist/services/introspection/auth.js +33 -0
  110. package/dist/services/introspection/auth.js.map +1 -0
  111. package/dist/services/introspection/errors.d.ts +6 -0
  112. package/dist/services/introspection/errors.js +50 -0
  113. package/dist/services/introspection/errors.js.map +1 -0
  114. package/dist/services/introspection/index.d.ts +53 -0
  115. package/dist/services/introspection/index.js +141 -0
  116. package/dist/services/introspection/index.js.map +1 -0
  117. package/dist/services/introspection/probe.d.ts +18 -0
  118. package/dist/services/introspection/probe.js +155 -0
  119. package/dist/services/introspection/probe.js.map +1 -0
  120. package/dist/services/period.d.ts +11 -0
  121. package/dist/services/period.js +68 -0
  122. package/dist/services/period.js.map +1 -0
  123. package/dist/services/request-log/capture.d.ts +10 -0
  124. package/dist/services/request-log/capture.js +189 -0
  125. package/dist/services/request-log/capture.js.map +1 -0
  126. package/dist/services/request-log/index.d.ts +3 -0
  127. package/dist/services/request-log/index.js +12 -0
  128. package/dist/services/request-log/index.js.map +1 -0
  129. package/dist/services/request-log/prune.d.ts +2 -0
  130. package/dist/services/request-log/prune.js +10 -0
  131. package/dist/services/request-log/prune.js.map +1 -0
  132. package/dist/services/request-log/read.d.ts +6 -0
  133. package/dist/services/request-log/read.js +26 -0
  134. package/dist/services/request-log/read.js.map +1 -0
  135. package/dist/services/request-log/redaction.d.ts +4 -0
  136. package/dist/services/request-log/redaction.js +53 -0
  137. package/dist/services/request-log/redaction.js.map +1 -0
  138. package/dist/services/request-log/util.d.ts +13 -0
  139. package/dist/services/request-log/util.js +114 -0
  140. package/dist/services/request-log/util.js.map +1 -0
  141. package/dist/services/routes-sync.d.ts +5 -0
  142. package/dist/services/routes-sync.js +63 -0
  143. package/dist/services/routes-sync.js.map +1 -0
  144. package/dist/services/scope.d.ts +7 -0
  145. package/dist/services/scope.js +40 -0
  146. package/dist/services/scope.js.map +1 -0
  147. package/dist/services/settings.d.ts +20 -0
  148. package/dist/services/settings.js +86 -0
  149. package/dist/services/settings.js.map +1 -0
  150. package/dist/services/statistics-aggregate.d.ts +67 -0
  151. package/dist/services/statistics-aggregate.js +340 -0
  152. package/dist/services/statistics-aggregate.js.map +1 -0
  153. package/dist/services/statistics-prune.d.ts +2 -0
  154. package/dist/services/statistics-prune.js +25 -0
  155. package/dist/services/statistics-prune.js.map +1 -0
  156. package/dist/services/statistics-read.d.ts +4 -0
  157. package/dist/services/statistics-read.js +48 -0
  158. package/dist/services/statistics-read.js.map +1 -0
  159. package/dist/services/statistics-utils.d.ts +14 -0
  160. package/dist/services/statistics-utils.js +65 -0
  161. package/dist/services/statistics-utils.js.map +1 -0
  162. package/dist/services/statistics-write.d.ts +3 -0
  163. package/dist/services/statistics-write.js +84 -0
  164. package/dist/services/statistics-write.js.map +1 -0
  165. package/dist/services/tree.d.ts +10 -0
  166. package/dist/services/tree.js +128 -0
  167. package/dist/services/tree.js.map +1 -0
  168. package/dist/types/charts.d.ts +9 -0
  169. package/dist/types/charts.js +3 -0
  170. package/dist/types/charts.js.map +1 -0
  171. package/dist/types/constants.d.ts +31 -0
  172. package/dist/types/constants.js +49 -0
  173. package/dist/types/constants.js.map +1 -0
  174. package/dist/types/index.d.ts +3 -0
  175. package/dist/types/index.js +20 -0
  176. package/dist/types/index.js.map +1 -0
  177. package/dist/types/statistics.d.ts +17 -0
  178. package/dist/types/statistics.js +3 -0
  179. package/dist/types/statistics.js.map +1 -0
  180. package/frontend-vue/.editorconfig +12 -0
  181. package/frontend-vue/.prettierrc +12 -0
  182. package/frontend-vue/.vscode/settings.json +26 -0
  183. package/frontend-vue/app/components/ConfigurationView.vue +187 -0
  184. package/frontend-vue/app/components/DocumentationView.vue +224 -0
  185. package/frontend-vue/app/components/LogDetailDrawer.vue +178 -0
  186. package/frontend-vue/app/components/LogsView.vue +347 -0
  187. package/frontend-vue/app/components/RouteDetailTabs.vue +179 -0
  188. package/frontend-vue/app/components/RouteTree.vue +196 -0
  189. package/frontend-vue/app/components/RoutesView.vue +82 -0
  190. package/frontend-vue/app/components/StatsView.vue +268 -0
  191. package/frontend-vue/app/components/SummaryView.vue +657 -0
  192. package/frontend-vue/app/components/TesterPanel.vue +499 -0
  193. package/frontend-vue/app/components/internal/ApiMethodBadge.vue +33 -0
  194. package/frontend-vue/app/components/internal/ApiStatusBadge.vue +28 -0
  195. package/frontend-vue/app/components/internal/PeriodSelect.vue +58 -0
  196. package/frontend-vue/app/components/internal/RouteTreeNode.vue +168 -0
  197. package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +162 -0
  198. package/frontend-vue/app/components/internal/StatusDonut.vue +84 -0
  199. package/frontend-vue/app/components/internal/UnitAreaChart.vue +73 -0
  200. package/frontend-vue/app/composables/useApiIntrospection.ts +344 -0
  201. package/frontend-vue/app/composables/useLogDetailDrawer.ts +50 -0
  202. package/frontend-vue/app/composables/useSelectedPeriod.ts +107 -0
  203. package/frontend-vue/app/composables/useStatsPeriods.ts +139 -0
  204. package/frontend-vue/app/custom-layouts/.gitkeep +0 -0
  205. package/frontend-vue/app/custom-pages/.gitkeep +0 -0
  206. package/frontend-vue/app/utils/httpMethod.ts +49 -0
  207. package/frontend-vue/app/utils/statusClass.ts +49 -0
  208. package/frontend-vue/app/utils/testerRequest.ts +50 -0
  209. package/frontend-vue/dms.frontend.ts +25 -0
  210. package/frontend-vue/eslint.config.mjs +16 -0
  211. package/frontend-vue/i18n/locales/en-GB.json +240 -0
  212. package/frontend-vue/i18n/locales/fr-FR.json +240 -0
  213. package/frontend-vue/package.json +35 -0
  214. package/frontend-vue/pnpm-lock.yaml +5796 -0
  215. package/frontend-vue/pnpm-workspace.yaml +2 -0
  216. package/frontend-vue/public/.gitkeep +0 -0
  217. package/frontend-vue/server/.gitkeep +0 -0
  218. package/frontend-vue/tests/periods.test.ts +145 -0
  219. package/frontend-vue/tests/persistence.test.ts +45 -0
  220. package/frontend-vue/tests/registration.test.ts +28 -0
  221. package/frontend-vue/tests/testerRequest.test.ts +95 -0
  222. package/frontend-vue/tsconfig.json +13 -0
  223. package/frontend-vue/vitest.config.ts +8 -0
  224. package/package.json +67 -0
@@ -0,0 +1,181 @@
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.SummaryController = 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 types_1 = require("@/types");
26
+ const DEFAULT_HISTORY_DAYS = 7;
27
+ const ACTIVITY_LIMIT = 10;
28
+ const WATCH_LIMIT = 4;
29
+ let SummaryController = class SummaryController extends (0, interface_api_1.Controller)("/api/monitoring/summary") {
30
+ async getSummary(_user) {
31
+ const [routes, stats] = models();
32
+ const keys = await (0, scope_1.getScopedRouteKeys)(routes, (0, settings_1.getActiveScope)());
33
+ const total = await countScopedRoutes(routes, keys);
34
+ const kpis = await (0, statistics_aggregate_1.getSummaryKpis)(stats, total, keys);
35
+ return {
36
+ kpis,
37
+ autoGeneratedCount: 0,
38
+ customCount: total,
39
+ };
40
+ }
41
+ async getHealth(_user) {
42
+ const [routes, stats] = models();
43
+ const keys = await (0, scope_1.getScopedRouteKeys)(routes, (0, settings_1.getActiveScope)());
44
+ const total = await countScopedRoutes(routes, keys);
45
+ const kpis = await (0, statistics_aggregate_1.getSummaryKpis)(stats, total, keys);
46
+ const errorRate = kpis.callsToday > 0 ? kpis.errors24h / kpis.callsToday : 0;
47
+ const lastIncident = await findLastIncident(keys);
48
+ return {
49
+ status: pickStatus(errorRate, kpis.slowRoutesCount),
50
+ errorRate,
51
+ averageLatencyMs: kpis.averageLatencyMs,
52
+ uptime: null,
53
+ lastIncidentAt: lastIncident?.timestamp ?? null,
54
+ };
55
+ }
56
+ async getHistory(_user, period) {
57
+ const days = (0, period_1.resolvePeriodDays)(period, DEFAULT_HISTORY_DAYS);
58
+ const keys = await (0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)());
59
+ return (0, statistics_aggregate_1.getRequestHistory)((0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel), days, keys);
60
+ }
61
+ async getStatusBreakdown(_user, period) {
62
+ const days = (0, period_1.parsePeriodDays)(period);
63
+ const keys = await (0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)());
64
+ return (0, statistics_aggregate_1.getStatusBreakdown)((0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel), days, keys);
65
+ }
66
+ async getWatchList(_user, limit) {
67
+ const lim = clampInt(limit, 1, 20, WATCH_LIMIT);
68
+ const keys = await (0, scope_1.getScopedRouteKeys)((0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, settings_1.getActiveScope)());
69
+ return (0, statistics_aggregate_1.getWatchList)((0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel), lim, keys);
70
+ }
71
+ async getActivity(_user) {
72
+ const routesModel = (0, interface_database_decorators_1.GetModel)(db_1.RouteModel);
73
+ const keys = await (0, scope_1.getScopedRouteKeys)(routesModel, (0, settings_1.getActiveScope)());
74
+ const errorPage = await (0, read_1.queryRequestLogsScoped)((0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), {
75
+ statusClass: "server-error",
76
+ limit: ACTIVITY_LIMIT,
77
+ }, keys);
78
+ const routes = await routesModel.getAll();
79
+ const recentRoutes = routes
80
+ .filter((r) => !keys || keys.has(`${r.method.toUpperCase()}:${r.uri}`))
81
+ .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
82
+ .slice(0, ACTIVITY_LIMIT)
83
+ .map((r) => ({
84
+ kind: "route-created",
85
+ timestamp: r.createdAt,
86
+ method: r.method,
87
+ uri: r.uri,
88
+ }));
89
+ const errors = errorPage.results.map((l) => ({
90
+ kind: "error",
91
+ timestamp: l.timestamp,
92
+ method: l.method,
93
+ uri: l.uri,
94
+ statusCode: l.statusCode,
95
+ }));
96
+ return [...recentRoutes, ...errors]
97
+ .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())
98
+ .slice(0, ACTIVITY_LIMIT);
99
+ }
100
+ };
101
+ exports.SummaryController = SummaryController;
102
+ __decorate([
103
+ (0, interface_api_1.Get)(""),
104
+ __param(0, (0, auth_1.AuthRawUser)()),
105
+ __metadata("design:type", Function),
106
+ __metadata("design:paramtypes", [Function]),
107
+ __metadata("design:returntype", Promise)
108
+ ], SummaryController.prototype, "getSummary", null);
109
+ __decorate([
110
+ (0, interface_api_1.Get)("health"),
111
+ __param(0, (0, auth_1.AuthRawUser)()),
112
+ __metadata("design:type", Function),
113
+ __metadata("design:paramtypes", [Function]),
114
+ __metadata("design:returntype", Promise)
115
+ ], SummaryController.prototype, "getHealth", null);
116
+ __decorate([
117
+ (0, interface_api_1.Get)("history"),
118
+ __param(0, (0, auth_1.AuthRawUser)()),
119
+ __param(1, (0, interface_api_1.Parameter)("period", "query")),
120
+ __metadata("design:type", Function),
121
+ __metadata("design:paramtypes", [Function, String]),
122
+ __metadata("design:returntype", Promise)
123
+ ], SummaryController.prototype, "getHistory", null);
124
+ __decorate([
125
+ (0, interface_api_1.Get)("status-breakdown"),
126
+ __param(0, (0, auth_1.AuthRawUser)()),
127
+ __param(1, (0, interface_api_1.Parameter)("period", "query")),
128
+ __metadata("design:type", Function),
129
+ __metadata("design:paramtypes", [Function, String]),
130
+ __metadata("design:returntype", Promise)
131
+ ], SummaryController.prototype, "getStatusBreakdown", null);
132
+ __decorate([
133
+ (0, interface_api_1.Get)("watch-list"),
134
+ __param(0, (0, auth_1.AuthRawUser)()),
135
+ __param(1, (0, interface_api_1.Parameter)("limit", "query")),
136
+ __metadata("design:type", Function),
137
+ __metadata("design:paramtypes", [Function, String]),
138
+ __metadata("design:returntype", Promise)
139
+ ], SummaryController.prototype, "getWatchList", null);
140
+ __decorate([
141
+ (0, interface_api_1.Get)("activity"),
142
+ __param(0, (0, auth_1.AuthRawUser)()),
143
+ __metadata("design:type", Function),
144
+ __metadata("design:paramtypes", [Function]),
145
+ __metadata("design:returntype", Promise)
146
+ ], SummaryController.prototype, "getActivity", null);
147
+ exports.SummaryController = SummaryController = __decorate([
148
+ (0, auth_1.AuthOwnerOnly)()
149
+ ], SummaryController);
150
+ function models() {
151
+ return [(0, interface_database_decorators_1.GetModel)(db_1.RouteModel), (0, interface_database_decorators_1.GetModel)(db_1.RouteStatisticsModel)];
152
+ }
153
+ async function countScopedRoutes(routes, keys) {
154
+ if (keys)
155
+ return keys.size;
156
+ return routes.table.count().run();
157
+ }
158
+ async function findLastIncident(keys) {
159
+ const page = await (0, read_1.queryRequestLogsScoped)((0, interface_database_decorators_1.GetModel)(db_1.RequestLogModel), {
160
+ statusClass: "server-error",
161
+ limit: 1,
162
+ }, keys);
163
+ return page.results[0];
164
+ }
165
+ function pickStatus(errorRate, slowCount) {
166
+ if (errorRate > types_1.CRITICAL_ERROR_RATE)
167
+ return "down";
168
+ if (errorRate > types_1.ELEVATED_ERROR_RATE || slowCount > types_1.DEGRADED_SLOW_ROUTES) {
169
+ return "degraded";
170
+ }
171
+ return "healthy";
172
+ }
173
+ function clampInt(raw, min, max, fallback) {
174
+ if (!raw)
175
+ return fallback;
176
+ const n = parseInt(raw, 10);
177
+ if (Number.isNaN(n))
178
+ return fallback;
179
+ return Math.max(min, Math.min(max, n));
180
+ }
181
+ //# sourceMappingURL=summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/routes/summary.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAuE;AACvE,6FAAqE;AACrE,yDAA4E;AAE5E,6BAMc;AACd,8CAAuE;AACvE,sDAAqE;AACrE,4CAAs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,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from "./introspection";
2
+ export * from "./request-log";
3
+ export * from "./routes-sync";
4
+ export * from "./scope";
5
+ export * from "./settings";
6
+ export * from "./statistics-aggregate";
7
+ export * from "./statistics-prune";
8
+ export * from "./statistics-read";
9
+ export * from "./statistics-utils";
10
+ export * from "./statistics-write";
11
+ export * from "./tree";
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./introspection"), exports);
18
+ __exportStar(require("./request-log"), exports);
19
+ __exportStar(require("./routes-sync"), exports);
20
+ __exportStar(require("./scope"), exports);
21
+ __exportStar(require("./settings"), exports);
22
+ __exportStar(require("./statistics-aggregate"), exports);
23
+ __exportStar(require("./statistics-prune"), exports);
24
+ __exportStar(require("./statistics-read"), exports);
25
+ __exportStar(require("./statistics-utils"), exports);
26
+ __exportStar(require("./statistics-write"), exports);
27
+ __exportStar(require("./tree"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,0CAAwB;AACxB,6CAA2B;AAC3B,yDAAuC;AACvC,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,yCAAuB"}
@@ -0,0 +1,4 @@
1
+ export interface AuthMiddlewareInput {
2
+ callbackName: string;
3
+ }
4
+ export declare function isAuthMiddleware(m: AuthMiddlewareInput): boolean;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAuthMiddleware = isAuthMiddleware;
4
+ const config_1 = require("@/config");
5
+ let cached = null;
6
+ let cachedSig = "";
7
+ function matcher() {
8
+ const cfg = (0, config_1.getConfig)();
9
+ const sig = `${cfg.authMiddlewareNamePatterns.join("|")}::${cfg.authMiddlewareCallbacks.join("|")}`;
10
+ if (cached && cachedSig === sig)
11
+ return cached;
12
+ const patterns = [];
13
+ for (const raw of cfg.authMiddlewareNamePatterns) {
14
+ try {
15
+ patterns.push(new RegExp(raw));
16
+ }
17
+ catch {
18
+ }
19
+ }
20
+ cached = {
21
+ patterns,
22
+ callbacks: new Set(cfg.authMiddlewareCallbacks),
23
+ };
24
+ cachedSig = sig;
25
+ return cached;
26
+ }
27
+ function isAuthMiddleware(m) {
28
+ const { patterns, callbacks } = matcher();
29
+ if (callbacks.has(m.callbackName))
30
+ return true;
31
+ return patterns.some((p) => p.test(m.callbackName));
32
+ }
33
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/services/introspection/auth.ts"],"names":[],"mappings":";;AAiDA,4CAIC;AAzCD,qCAAqC;AAYrC,IAAI,MAAM,GAA2B,IAAI,CAAC;AAC1C,IAAI,SAAS,GAAG,EAAE,CAAC;AAEnB,SAAS,OAAO;IACd,MAAM,GAAG,GAAG,IAAA,kBAAS,GAAE,CAAC;IACxB,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACpG,IAAI,MAAM,IAAI,SAAS,KAAK,GAAG;QAAE,OAAO,MAAM,CAAC;IAE/C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,0BAA0B,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;QAGT,CAAC;IACH,CAAC;IACD,MAAM,GAAG;QACP,QAAQ;QACR,SAAS,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC;KAChD,CAAC;IACF,SAAS,GAAG,GAAG,CAAC;IAChB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,gBAAgB,CAAC,CAAsB;IACrD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;IAC1C,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface InferredErrorCode {
2
+ status: number;
3
+ reason: string | null;
4
+ source: "assert" | "HTTPResult";
5
+ }
6
+ export declare function probeHandlerErrors(handler: unknown): InferredErrorCode[];
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.probeHandlerErrors = probeHandlerErrors;
4
+ const ASSERT_PATTERN = /\bassert\)?\s*\(\s*[^,)]+,\s*(\d{3})(?:\s*,\s*(?:['"`])([^'"`]*)(?:['"`]))?/g;
5
+ const HTTP_RESULT_PATTERN = /\b(?:new\s+)?(?:[A-Za-z_$][\w$]*\.)?HTTPResult\)?\s*\(\s*(\d{3})(?:\s*,\s*(?:['"`])([^'"`]*)(?:['"`]))?/g;
6
+ function probeHandlerErrors(handler) {
7
+ const source = handlerSource(handler);
8
+ if (!source)
9
+ return [];
10
+ const found = new Map();
11
+ for (const match of source.matchAll(ASSERT_PATTERN)) {
12
+ const status = Number.parseInt(match[1], 10);
13
+ if (!isPlausibleErrorStatus(status))
14
+ continue;
15
+ if (!found.has(status)) {
16
+ found.set(status, {
17
+ status,
18
+ reason: match[2] ?? null,
19
+ source: "assert",
20
+ });
21
+ }
22
+ }
23
+ for (const match of source.matchAll(HTTP_RESULT_PATTERN)) {
24
+ const status = Number.parseInt(match[1], 10);
25
+ if (!isPlausibleErrorStatus(status))
26
+ continue;
27
+ if (!found.has(status)) {
28
+ found.set(status, {
29
+ status,
30
+ reason: match[2] ?? null,
31
+ source: "HTTPResult",
32
+ });
33
+ }
34
+ }
35
+ return [...found.values()].sort((a, b) => a.status - b.status);
36
+ }
37
+ function handlerSource(fn) {
38
+ if (typeof fn !== "function")
39
+ return "";
40
+ try {
41
+ return Function.prototype.toString.call(fn);
42
+ }
43
+ catch {
44
+ return "";
45
+ }
46
+ }
47
+ function isPlausibleErrorStatus(status) {
48
+ return status >= 400 && status < 600;
49
+ }
50
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/services/introspection/errors.ts"],"names":[],"mappings":";;AA4BA,gDA+BC;AArCD,MAAM,cAAc,GAClB,8EAA8E,CAAC;AAEjF,MAAM,mBAAmB,GACvB,0GAA0G,CAAC;AAE7G,SAAgB,kBAAkB,CAAC,OAAgB;IACjD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IA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AAE,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAc;IAC5C,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC;AACvC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type RouteHandlerMode } from "@antelopejs/interface-api";
2
+ import { isAuthMiddleware } from "./auth";
3
+ import { type InferredErrorCode } from "./errors";
4
+ import { type InferredType, type ParameterSource } from "./probe";
5
+ export { isAuthMiddleware };
6
+ export type { InferredErrorCode, InferredType, ParameterSource };
7
+ export interface ParameterInfo {
8
+ index: number;
9
+ name: string | null;
10
+ source: ParameterSource;
11
+ multi: boolean;
12
+ inferredType: InferredType;
13
+ modifierCount: number;
14
+ rawProviderSource?: string;
15
+ hint?: string;
16
+ }
17
+ export interface PropertyInfo {
18
+ key: string;
19
+ decorator: string;
20
+ modifierCount: number;
21
+ rawProviderSource?: string;
22
+ hint?: string;
23
+ }
24
+ export type MiddlewareMode = "prefix" | "postfix" | "monitor";
25
+ export interface MiddlewareInfo {
26
+ id: string;
27
+ mode: MiddlewareMode;
28
+ location: string;
29
+ method: string;
30
+ callbackName: string;
31
+ priority?: number;
32
+ isAuth: boolean;
33
+ }
34
+ export interface RouteInspection {
35
+ id: string;
36
+ location: string;
37
+ method: string;
38
+ mode: RouteHandlerMode;
39
+ callbackName: string;
40
+ priority?: number;
41
+ parameters: ParameterInfo[];
42
+ properties: PropertyInfo[];
43
+ applicableMiddleware: MiddlewareInfo[];
44
+ errorCodes: InferredErrorCode[];
45
+ }
46
+ export interface FolderInspection {
47
+ path: string;
48
+ middlewareAtOrAbove: MiddlewareInfo[];
49
+ routes: RouteInspection[];
50
+ }
51
+ export declare function getRouteInspection(id: string): RouteInspection | undefined;
52
+ export declare function listRouteInspections(): RouteInspection[];
53
+ export declare function getFolderInspection(urlPath: string): FolderInspection;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAuthMiddleware = void 0;
4
+ exports.getRouteInspection = getRouteInspection;
5
+ exports.listRouteInspections = listRouteInspections;
6
+ exports.getFolderInspection = getFolderInspection;
7
+ const interface_api_1 = require("@antelopejs/interface-api");
8
+ const auth_1 = require("./auth");
9
+ Object.defineProperty(exports, "isAuthMiddleware", { enumerable: true, get: function () { return auth_1.isAuthMiddleware; } });
10
+ const errors_1 = require("./errors");
11
+ const probe_1 = require("./probe");
12
+ const MIDDLEWARE_MODES = new Set([
13
+ "prefix",
14
+ "postfix",
15
+ "monitor",
16
+ ]);
17
+ function inspectParameter(param, index) {
18
+ const probed = (0, probe_1.probeProvider)(param);
19
+ return {
20
+ index,
21
+ name: probed.name,
22
+ source: probed.source,
23
+ multi: probed.multi,
24
+ inferredType: probed.inferredType,
25
+ modifierCount: param?.modifiers.length ?? 0,
26
+ rawProviderSource: probed.rawProviderSource,
27
+ hint: probed.hint,
28
+ };
29
+ }
30
+ function inspectProperties(properties) {
31
+ return Object.entries(properties).map(([key, param]) => {
32
+ const probed = (0, probe_1.probeProperty)(param);
33
+ return {
34
+ key,
35
+ decorator: probed.decorator,
36
+ modifierCount: param.modifiers.length,
37
+ rawProviderSource: probed.rawProviderSource,
38
+ hint: probed.hint,
39
+ };
40
+ });
41
+ }
42
+ function middlewareMatches(middlewareLocation, middlewareMethod, routeLocation, routeMethod) {
43
+ if (middlewareMethod !== "any" &&
44
+ middlewareMethod.toLowerCase() !== routeMethod.toLowerCase()) {
45
+ return false;
46
+ }
47
+ return locationCovers(middlewareLocation, routeLocation);
48
+ }
49
+ function locationCovers(prefix, full) {
50
+ const prefixSegs = prefix.split("/").filter(Boolean);
51
+ const fullSegs = full.split("/").filter(Boolean);
52
+ if (prefixSegs.length > fullSegs.length)
53
+ return false;
54
+ for (let i = 0; i < prefixSegs.length; i++) {
55
+ const a = prefixSegs[i];
56
+ const b = fullSegs[i];
57
+ if (a.startsWith(":") || a.startsWith("::"))
58
+ continue;
59
+ if (a !== b)
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+ function toMiddlewareInfo(id, handler) {
65
+ const callbackName = handler.callback.name || "anonymous";
66
+ return {
67
+ id,
68
+ mode: handler.mode,
69
+ location: handler.location,
70
+ method: handler.method,
71
+ callbackName,
72
+ priority: handler.priority,
73
+ isAuth: (0, auth_1.isAuthMiddleware)({ callbackName }),
74
+ };
75
+ }
76
+ function listMiddlewareEntries() {
77
+ return (0, interface_api_1.getRegisteredRouteHandlers)().filter(({ handler }) => MIDDLEWARE_MODES.has(handler.mode));
78
+ }
79
+ function applicableMiddleware(routeLocation, routeMethod) {
80
+ return listMiddlewareEntries()
81
+ .filter(({ handler }) => middlewareMatches(handler.location, handler.method, routeLocation, routeMethod))
82
+ .sort(comparePriorityThenMode)
83
+ .map(({ id, handler }) => toMiddlewareInfo(id, handler));
84
+ }
85
+ function comparePriorityThenMode(a, b) {
86
+ const modeOrder = {
87
+ prefix: 0,
88
+ postfix: 1,
89
+ monitor: 2,
90
+ handler: 3,
91
+ websocket: 4,
92
+ };
93
+ const am = modeOrder[a.handler.mode] ?? 99;
94
+ const bm = modeOrder[b.handler.mode] ?? 99;
95
+ if (am !== bm)
96
+ return am - bm;
97
+ const ap = a.handler.priority ?? 2;
98
+ const bp = b.handler.priority ?? 2;
99
+ return ap - bp;
100
+ }
101
+ function inspectHandler(id, handler) {
102
+ return {
103
+ id,
104
+ location: handler.location,
105
+ method: handler.method,
106
+ mode: handler.mode,
107
+ callbackName: handler.callback.name || "anonymous",
108
+ priority: handler.priority,
109
+ parameters: handler.parameters.map(inspectParameter),
110
+ properties: inspectProperties(handler.properties),
111
+ applicableMiddleware: handler.mode === "handler"
112
+ ? applicableMiddleware(handler.location, handler.method)
113
+ : [],
114
+ errorCodes: handler.mode === "handler" ? (0, errors_1.probeHandlerErrors)(handler.callback) : [],
115
+ };
116
+ }
117
+ function getRouteInspection(id) {
118
+ const registered = (0, interface_api_1.getRegisteredRouteHandlers)().find((route) => route.id === id);
119
+ if (!registered)
120
+ return undefined;
121
+ return inspectHandler(registered.id, registered.handler);
122
+ }
123
+ function listRouteInspections() {
124
+ return (0, interface_api_1.getRegisteredRouteHandlers)()
125
+ .filter(({ handler }) => handler.mode === "handler")
126
+ .map(({ id, handler }) => inspectHandler(id, handler));
127
+ }
128
+ function getFolderInspection(urlPath) {
129
+ const normalized = `/${urlPath.split("/").filter(Boolean).join("/")}`;
130
+ const routes = listRouteInspections().filter((route) => locationCovers(normalized, route.location));
131
+ const middlewareAtOrAbove = listMiddlewareEntries()
132
+ .filter(({ handler }) => locationCovers(handler.location, normalized))
133
+ .sort(comparePriorityThenMode)
134
+ .map(({ id, handler }) => toMiddlewareInfo(id, handler));
135
+ return {
136
+ path: normalized,
137
+ middlewareAtOrAbove,
138
+ routes,
139
+ };
140
+ }
141
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/introspection/index.ts"],"names":[],"mappings":";;;AA2OA,gDAMC;AAED,oDAIC;AAED,kDAeC;AA1PD,6DAMmC;AACnC,iCAA0C;AASjC,iGATA,uBAAgB,OASA;AARzB,qCAAsE;AACtE,mCAKiB;AAuDjB,MAAM,gBAAgB,GAAkC,IAAI,GAAG,CAAC;IAC9D,QAAQ;IACR,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAEH,SAAS,gBAAgB,CACvB,KAA+B,EAC/B,KAAa;IAEb,MAAM,MAAM,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IACpC,OAAO;QACL,KAAK;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,C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mBAAmB,GAAG,qBAAqB,EAAE;SAChD,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;SACrE,IAAI,CAAC,uBAAuB,CAAC;SAC7B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,mBAAmB;QACnB,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ComputedParameter } from "@antelopejs/interface-api";
2
+ export type ParameterSource = "body" | "query" | "param" | "header" | "context" | "result" | "raw" | "stream" | "connection" | "unknown";
3
+ export type InferredType = "string" | "number" | "boolean" | "object" | "buffer" | "stream" | "unknown";
4
+ export interface ProbedParameter {
5
+ source: ParameterSource;
6
+ name: string | null;
7
+ multi: boolean;
8
+ inferredType: InferredType;
9
+ rawProviderSource?: string;
10
+ hint?: string;
11
+ }
12
+ export declare function probeProvider(param: ComputedParameter | null): ProbedParameter;
13
+ export interface ProbedProperty {
14
+ decorator: string;
15
+ rawProviderSource?: string;
16
+ hint?: string;
17
+ }
18
+ export declare function probeProperty(param: ComputedParameter): ProbedProperty;