nestlens 0.10.1 → 0.11.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.
Files changed (252) hide show
  1. package/README.md +1 -1
  2. package/dist/api/api.controller.d.ts +41 -23
  3. package/dist/api/api.controller.js +106 -147
  4. package/dist/api/api.guard.d.ts +46 -4
  5. package/dist/api/api.guard.js +145 -42
  6. package/dist/api/constants/error-codes.d.ts +2 -0
  7. package/dist/api/constants/error-codes.js +7 -0
  8. package/dist/api/dashboard-server.js +16 -9
  9. package/dist/api/dashboard.controller.js +12 -1
  10. package/dist/api/dto/cursor-query.dto.d.ts +23 -0
  11. package/dist/api/dto/cursor-query.dto.js +37 -22
  12. package/dist/api/dto/entries-query.dto.d.ts +57 -0
  13. package/dist/api/dto/entries-query.dto.js +140 -0
  14. package/dist/api/dto/entry-types.d.ts +9 -0
  15. package/dist/api/dto/entry-types.js +31 -0
  16. package/dist/api/dto/index.d.ts +2 -0
  17. package/dist/api/dto/index.js +2 -0
  18. package/dist/api/dto/tags.dto.d.ts +22 -0
  19. package/dist/api/dto/tags.dto.js +47 -4
  20. package/dist/api/dto/transformers/query-transformers.d.ts +38 -1
  21. package/dist/api/dto/transformers/query-transformers.js +55 -4
  22. package/dist/api/filters/api-exception.filter.d.ts +11 -0
  23. package/dist/api/filters/api-exception.filter.js +30 -3
  24. package/dist/api/pipes/nestlens-validation.pipe.js +12 -0
  25. package/dist/api/route-path.d.ts +7 -4
  26. package/dist/api/route-path.js +50 -6
  27. package/dist/api/tag.controller.d.ts +2 -2
  28. package/dist/api/tag.controller.js +5 -11
  29. package/dist/core/alerting.service.d.ts +21 -0
  30. package/dist/core/alerting.service.js +71 -2
  31. package/dist/core/client-ip.d.ts +40 -0
  32. package/dist/core/client-ip.js +58 -0
  33. package/dist/core/collector.service.d.ts +50 -0
  34. package/dist/core/collector.service.js +131 -6
  35. package/dist/core/data-masker.service.d.ts +109 -0
  36. package/dist/core/data-masker.service.js +397 -38
  37. package/dist/core/family-hash.service.d.ts +0 -6
  38. package/dist/core/family-hash.service.js +37 -6
  39. package/dist/core/masking-terms.d.ts +4 -2
  40. package/dist/core/pruning.service.d.ts +48 -1
  41. package/dist/core/pruning.service.js +78 -16
  42. package/dist/core/safe-assign.d.ts +33 -0
  43. package/dist/core/safe-assign.js +47 -0
  44. package/dist/core/storage/entry-filter.d.ts +10 -0
  45. package/dist/core/storage/entry-filter.js +135 -15
  46. package/dist/core/storage/memory.storage.d.ts +12 -0
  47. package/dist/core/storage/memory.storage.js +41 -3
  48. package/dist/core/storage/redis.storage.d.ts +191 -2
  49. package/dist/core/storage/redis.storage.js +673 -169
  50. package/dist/core/storage/serialize-payload.d.ts +17 -0
  51. package/dist/core/storage/serialize-payload.js +30 -0
  52. package/dist/core/storage/sqlite.storage.d.ts +117 -8
  53. package/dist/core/storage/sqlite.storage.js +330 -61
  54. package/dist/core/storage/storage.factory.d.ts +13 -0
  55. package/dist/core/storage/storage.factory.js +32 -4
  56. package/dist/core/storage/tag-normalization.d.ts +30 -0
  57. package/dist/core/storage/tag-normalization.js +32 -1
  58. package/dist/core/tag.service.js +24 -6
  59. package/dist/core/thenable.d.ts +30 -0
  60. package/dist/core/thenable.js +35 -0
  61. package/dist/dashboard/public/assets/BatchDetailView-DrhTmEz-.js +1 -0
  62. package/dist/dashboard/public/assets/BatchesPage-D0OIyUR0.js +1 -0
  63. package/dist/dashboard/public/assets/{CacheDetailView-BDg0OXAi.js → CacheDetailView-BbinMoJd.js} +1 -1
  64. package/dist/dashboard/public/assets/CachePage-BNZziysa.js +1 -0
  65. package/dist/dashboard/public/assets/CommandDetailView-cXUGT93v.js +1 -0
  66. package/dist/dashboard/public/assets/CommandsPage-DIjvN8Tm.js +1 -0
  67. package/dist/dashboard/public/assets/{CopyButton-oI0f2BPa.js → CopyButton-DO0tQZap.js} +1 -1
  68. package/dist/dashboard/public/assets/DashboardPage-Bu2tjEtU.js +21 -0
  69. package/dist/dashboard/public/assets/DataTable-B5pCZtzn.js +53 -0
  70. package/dist/dashboard/public/assets/DetailRow-CILUtuHz.js +1 -0
  71. package/dist/dashboard/public/assets/{DumpDetailView-c1-zovWx.js → DumpDetailView-CN-92Xh3.js} +1 -1
  72. package/dist/dashboard/public/assets/DumpsPage-XzXWa2Zx.js +1 -0
  73. package/dist/dashboard/public/assets/EntryDetailPage-BeNP5KQe.js +27 -0
  74. package/dist/dashboard/public/assets/{EntrySearchInput-ZRceRlzI.js → EntrySearchInput-D9Luyii-.js} +1 -1
  75. package/dist/dashboard/public/assets/EventDetailView-CfROsYnP.js +1 -0
  76. package/dist/dashboard/public/assets/EventsPage-CGd4ilHn.js +1 -0
  77. package/dist/dashboard/public/assets/{ExceptionDetailView-BguHjEHJ.js → ExceptionDetailView-CR_YtAt5.js} +1 -1
  78. package/dist/dashboard/public/assets/ExceptionsPage-CzRqVNKO.js +6 -0
  79. package/dist/dashboard/public/assets/{GateDetailView-NwkvH8ib.js → GateDetailView-Mm2OKdJd.js} +1 -1
  80. package/dist/dashboard/public/assets/GatesPage-BDu7ZKzg.js +1 -0
  81. package/dist/dashboard/public/assets/GraphQLDetailView-CDCSxpoQ.js +6 -0
  82. package/dist/dashboard/public/assets/GraphQLPage-BFcNcF2K.js +6 -0
  83. package/dist/dashboard/public/assets/HttpClientDetailView-BKDaf1kG.js +1 -0
  84. package/dist/dashboard/public/assets/HttpClientPage-DsLiAk3o.js +1 -0
  85. package/dist/dashboard/public/assets/{JobDetailView-Do3XVw-b.js → JobDetailView-vzz_69RD.js} +1 -1
  86. package/dist/dashboard/public/assets/JobsPage-DwKKclmA.js +1 -0
  87. package/dist/dashboard/public/assets/LogDetailView-BhtlmeVV.js +1 -0
  88. package/dist/dashboard/public/assets/LogsPage-jIsp8Im3.js +1 -0
  89. package/dist/dashboard/public/assets/{MailDetailView-FNWdO4I6.js → MailDetailView-fyzHsAnK.js} +4 -4
  90. package/dist/dashboard/public/assets/MailPage-QeD7ZYIv.js +1 -0
  91. package/dist/dashboard/public/assets/ModelDetailView--MfEk7iV.js +1 -0
  92. package/dist/dashboard/public/assets/ModelsPage-DcpvidHe.js +1 -0
  93. package/dist/dashboard/public/assets/NotificationDetailView-DcSDXMCX.js +1 -0
  94. package/dist/dashboard/public/assets/NotificationsPage-9HLS-Dj0.js +1 -0
  95. package/dist/dashboard/public/assets/PageHeader-BbUQ6Fod.js +1 -0
  96. package/dist/dashboard/public/assets/QueriesPage-UAD6LBc3.js +1 -0
  97. package/dist/dashboard/public/assets/{QueryDetailView-58AnmJUd.js → QueryDetailView-D1TlCQwd.js} +1 -1
  98. package/dist/dashboard/public/assets/RedisDetailView-yxO7EOBv.js +1 -0
  99. package/dist/dashboard/public/assets/RedisPage-B-EnnsXI.js +1 -0
  100. package/dist/dashboard/public/assets/RequestDetailView-DpYYfFcS.js +1 -0
  101. package/dist/dashboard/public/assets/RequestsPage-DMsx7tQE.js +1 -0
  102. package/dist/dashboard/public/assets/ScheduleDetailView-t4Btd9LI.js +1 -0
  103. package/dist/dashboard/public/assets/SchedulePage-CxBJpgGv.js +1 -0
  104. package/dist/dashboard/public/assets/UserCard-fi9kRol2.js +1 -0
  105. package/dist/dashboard/public/assets/ViewDetailView-CX7dgrtr.js +1 -0
  106. package/dist/dashboard/public/assets/ViewsPage-B4XLebCW.js +1 -0
  107. package/dist/dashboard/public/assets/{calendar-iGz7imq4.js → calendar-DImlwX3C.js} +1 -1
  108. package/dist/dashboard/public/assets/{circle-alert-BRXuJPBy.js → circle-alert-t7DmSwSk.js} +1 -1
  109. package/dist/dashboard/public/assets/{circle-check-big-DVxhxYns.js → circle-check-big-BVE5y5eW.js} +1 -1
  110. package/dist/dashboard/public/assets/{circle-x-v0VbdG9M.js → circle-x-CjxRvM2o.js} +1 -1
  111. package/dist/dashboard/public/assets/{badgeColors-DQ_P_DOX.js → date-Dwgqy666.js} +1 -1
  112. package/dist/dashboard/public/assets/{eye-DcMaRsYF.js → eye-RW0AAbBn.js} +1 -1
  113. package/dist/dashboard/public/assets/index-C256oDAK.css +1 -0
  114. package/dist/dashboard/public/assets/index-CAvLri3a.js +361 -0
  115. package/dist/dashboard/public/assets/{search-BERxF7dG.js → search-Dx7bxjJ6.js} +1 -1
  116. package/dist/dashboard/public/assets/{send-IiapMYKZ.js → send-OVSDC_zi.js} +1 -1
  117. package/dist/dashboard/public/assets/{timer-2vIduyIC.js → timer-BPIGHr0_.js} +1 -1
  118. package/dist/dashboard/public/assets/types-zWn317o-.js +1 -0
  119. package/dist/dashboard/public/assets/{users-BlF2EBBP.js → users-DGZXeIpK.js} +1 -1
  120. package/dist/dashboard/public/assets/{zap-CEj-5YGt.js → zap-BF90FAId.js} +1 -1
  121. package/dist/dashboard/public/index.html +2 -2
  122. package/dist/index.d.ts +16 -2
  123. package/dist/index.js +58 -22
  124. package/dist/nestlens.config.d.ts +27 -2
  125. package/dist/nestlens.config.js +1 -0
  126. package/dist/nestlens.module.d.ts +10 -0
  127. package/dist/nestlens.module.js +39 -1
  128. package/dist/types/entry.types.d.ts +32 -11
  129. package/dist/types/graphql.types.d.ts +18 -1
  130. package/dist/types/graphql.types.js +19 -0
  131. package/dist/types/tag.types.d.ts +0 -16
  132. package/dist/watchers/batch.watcher.d.ts +4 -5
  133. package/dist/watchers/batch.watcher.js +18 -45
  134. package/dist/watchers/cache.watcher.js +2 -14
  135. package/dist/watchers/capture-payload.d.ts +21 -0
  136. package/dist/watchers/capture-payload.js +34 -0
  137. package/dist/watchers/command.watcher.d.ts +0 -1
  138. package/dist/watchers/command.watcher.js +3 -19
  139. package/dist/watchers/dump.watcher.d.ts +4 -3
  140. package/dist/watchers/dump.watcher.js +14 -33
  141. package/dist/watchers/event.watcher.d.ts +14 -2
  142. package/dist/watchers/event.watcher.js +22 -16
  143. package/dist/watchers/exception.watcher.d.ts +41 -4
  144. package/dist/watchers/exception.watcher.js +59 -19
  145. package/dist/watchers/gate.watcher.d.ts +12 -4
  146. package/dist/watchers/gate.watcher.js +21 -32
  147. package/dist/watchers/graphql/adapters/apollo.adapter.d.ts +18 -0
  148. package/dist/watchers/graphql/adapters/apollo.adapter.js +285 -181
  149. package/dist/watchers/graphql/adapters/base.adapter.d.ts +7 -0
  150. package/dist/watchers/graphql/adapters/base.adapter.js +17 -38
  151. package/dist/watchers/graphql/adapters/mercurius.adapter.d.ts +56 -34
  152. package/dist/watchers/graphql/adapters/mercurius.adapter.js +101 -26
  153. package/dist/watchers/graphql/field-instrumentation.d.ts +15 -0
  154. package/dist/watchers/graphql/field-instrumentation.js +119 -0
  155. package/dist/watchers/graphql/graphql.watcher.d.ts +37 -15
  156. package/dist/watchers/graphql/graphql.watcher.js +77 -46
  157. package/dist/watchers/graphql/index.d.ts +8 -8
  158. package/dist/watchers/graphql/index.js +4 -22
  159. package/dist/watchers/graphql/never-breaks-the-response.d.ts +20 -0
  160. package/dist/watchers/graphql/never-breaks-the-response.js +83 -0
  161. package/dist/watchers/graphql/subscription/connection.store.d.ts +6 -12
  162. package/dist/watchers/graphql/subscription/connection.store.js +9 -28
  163. package/dist/watchers/graphql/subscription/index.d.ts +1 -1
  164. package/dist/watchers/graphql/subscription/index.js +1 -1
  165. package/dist/watchers/graphql/subscription/schema-instrumentation.d.ts +6 -0
  166. package/dist/watchers/graphql/subscription/schema-instrumentation.js +227 -0
  167. package/dist/watchers/graphql/subscription/subscription.tracker.d.ts +0 -1
  168. package/dist/watchers/graphql/subscription/subscription.tracker.js +25 -23
  169. package/dist/watchers/graphql/types.d.ts +10 -1
  170. package/dist/watchers/graphql/types.js +6 -1
  171. package/dist/watchers/graphql/utils/depth-calculator.d.ts +0 -13
  172. package/dist/watchers/graphql/utils/depth-calculator.js +0 -87
  173. package/dist/watchers/graphql/utils/field-tracer.d.ts +0 -50
  174. package/dist/watchers/graphql/utils/field-tracer.js +6 -90
  175. package/dist/watchers/graphql/utils/n1-detector.d.ts +14 -35
  176. package/dist/watchers/graphql/utils/n1-detector.js +14 -72
  177. package/dist/watchers/graphql/utils/query-parser.d.ts +60 -15
  178. package/dist/watchers/graphql/utils/query-parser.js +209 -50
  179. package/dist/watchers/graphql/utils/variable-sanitizer.d.ts +0 -7
  180. package/dist/watchers/graphql/utils/variable-sanitizer.js +27 -17
  181. package/dist/watchers/http-client.watcher.d.ts +29 -2
  182. package/dist/watchers/http-client.watcher.js +69 -43
  183. package/dist/watchers/job.watcher.d.ts +48 -4
  184. package/dist/watchers/job.watcher.js +90 -52
  185. package/dist/watchers/log.watcher.d.ts +20 -0
  186. package/dist/watchers/log.watcher.js +33 -1
  187. package/dist/watchers/mail.watcher.d.ts +21 -1
  188. package/dist/watchers/mail.watcher.js +59 -44
  189. package/dist/watchers/model.watcher.d.ts +63 -4
  190. package/dist/watchers/model.watcher.js +132 -157
  191. package/dist/watchers/notification.watcher.js +14 -33
  192. package/dist/watchers/query/query.watcher.d.ts +25 -0
  193. package/dist/watchers/query/query.watcher.js +79 -11
  194. package/dist/watchers/query/types.d.ts +0 -1
  195. package/dist/watchers/query/types.js +0 -13
  196. package/dist/watchers/redis.watcher.d.ts +8 -0
  197. package/dist/watchers/redis.watcher.js +26 -46
  198. package/dist/watchers/request.watcher.d.ts +8 -0
  199. package/dist/watchers/request.watcher.js +28 -23
  200. package/dist/watchers/schedule.watcher.d.ts +68 -5
  201. package/dist/watchers/schedule.watcher.js +218 -46
  202. package/dist/watchers/thrown-value.d.ts +33 -0
  203. package/dist/watchers/thrown-value.js +89 -0
  204. package/dist/watchers/view.watcher.d.ts +26 -3
  205. package/dist/watchers/view.watcher.js +35 -28
  206. package/dist/watchers/watcher-config.d.ts +5 -3
  207. package/dist/watchers/watcher-config.js +5 -3
  208. package/dist/watchers/wrap-method.d.ts +36 -0
  209. package/dist/watchers/wrap-method.js +135 -0
  210. package/package.json +11 -1
  211. package/dist/dashboard/public/assets/BatchDetailView-BA_QXL7a.js +0 -1
  212. package/dist/dashboard/public/assets/BatchesPage-D4oKMowE.js +0 -1
  213. package/dist/dashboard/public/assets/CachePage-BZKgOAHR.js +0 -1
  214. package/dist/dashboard/public/assets/CommandDetailView-CbQKT7r5.js +0 -1
  215. package/dist/dashboard/public/assets/CommandsPage-BhYsUquS.js +0 -1
  216. package/dist/dashboard/public/assets/DashboardPage-w7CPjb-N.js +0 -16
  217. package/dist/dashboard/public/assets/DataTable-D39w-diZ.js +0 -53
  218. package/dist/dashboard/public/assets/DetailRow-BaSzSd02.js +0 -1
  219. package/dist/dashboard/public/assets/DumpsPage-94vKqo6p.js +0 -1
  220. package/dist/dashboard/public/assets/EntryDetailPage-CVC4IBjE.js +0 -27
  221. package/dist/dashboard/public/assets/EventDetailView-lK4heuew.js +0 -1
  222. package/dist/dashboard/public/assets/EventsPage-MzZxRRE9.js +0 -1
  223. package/dist/dashboard/public/assets/ExceptionsPage-DHGFjUxu.js +0 -6
  224. package/dist/dashboard/public/assets/GatesPage-D9K4YB2k.js +0 -1
  225. package/dist/dashboard/public/assets/GraphQLDetailView-PkcaoZ15.js +0 -6
  226. package/dist/dashboard/public/assets/GraphQLPage-C0vODDMm.js +0 -6
  227. package/dist/dashboard/public/assets/HttpClientDetailView-N79x9PvH.js +0 -1
  228. package/dist/dashboard/public/assets/HttpClientPage-C4uuDTkf.js +0 -1
  229. package/dist/dashboard/public/assets/JobsPage-Clr2WV32.js +0 -1
  230. package/dist/dashboard/public/assets/LogDetailView-pxP_iVYL.js +0 -1
  231. package/dist/dashboard/public/assets/LogsPage-CsuPichq.js +0 -1
  232. package/dist/dashboard/public/assets/MailPage-B7i0Esr8.js +0 -1
  233. package/dist/dashboard/public/assets/ModelDetailView-LhtccX11.js +0 -1
  234. package/dist/dashboard/public/assets/ModelsPage-Dob5tidP.js +0 -1
  235. package/dist/dashboard/public/assets/NotificationDetailView-RxHmfj-e.js +0 -1
  236. package/dist/dashboard/public/assets/NotificationsPage-C-HehjQ8.js +0 -1
  237. package/dist/dashboard/public/assets/PageHeader-BNjXB_Ja.js +0 -1
  238. package/dist/dashboard/public/assets/QueriesPage-DiA6xvVI.js +0 -1
  239. package/dist/dashboard/public/assets/RedisDetailView-B1CVesM0.js +0 -1
  240. package/dist/dashboard/public/assets/RedisPage-DQz69JsJ.js +0 -1
  241. package/dist/dashboard/public/assets/RequestDetailView-BlOK9Jv_.js +0 -1
  242. package/dist/dashboard/public/assets/RequestsPage-KWb78XZC.js +0 -1
  243. package/dist/dashboard/public/assets/ScheduleDetailView-GkR80TZl.js +0 -1
  244. package/dist/dashboard/public/assets/SchedulePage-GRqVQK96.js +0 -1
  245. package/dist/dashboard/public/assets/UserCard-BuRugclY.js +0 -1
  246. package/dist/dashboard/public/assets/ViewDetailView-Df4tzNxi.js +0 -1
  247. package/dist/dashboard/public/assets/ViewsPage-B3VLpJgd.js +0 -1
  248. package/dist/dashboard/public/assets/index-B9BCPNKv.css +0 -1
  249. package/dist/dashboard/public/assets/index-w_yLpa1c.js +0 -361
  250. package/dist/dashboard/public/assets/types-BblOEq1q.js +0 -1
  251. package/dist/watchers/graphql/subscription/ws-gateway.d.ts +0 -120
  252. package/dist/watchers/graphql/subscription/ws-gateway.js +0 -255
package/README.md CHANGED
@@ -54,7 +54,7 @@ Watch requests, queries, and exceptions as they happen. No more console.log debu
54
54
 
55
55
  ### ✨ Zero Configuration
56
56
 
57
- Import and go. Works with Express & Fastify. Auto-detects TypeORM, Prisma, Bull, and more.
57
+ Import and go. Works with Express & Fastify. Finds your TypeORM queries, GraphQL server and scheduled tasks on its own; Prisma, Bull and the rest take one line each.
58
58
 
59
59
  </td>
60
60
  <td width="33%" valign="top">
@@ -2,8 +2,8 @@ import { StorageInterface } from '../core';
2
2
  import { PruningService } from '../core';
3
3
  import { CollectorService } from '../core';
4
4
  import { NestLensConfig } from '../nestlens.config';
5
- import { EntryType, CursorPaginatedResponse, Entry } from '../types';
6
- import { CursorQueryDto, PauseRecordingDto } from './dto';
5
+ import { CursorPaginatedResponse, Entry } from '../types';
6
+ import { CheckNewQueryDto, CursorQueryDto, EntriesQueryDto, LatestSequenceQueryDto, LogsQueryDto, PauseRecordingDto, QueriesQueryDto } from './dto';
7
7
  /**
8
8
  * Every handler here takes an unused `@Res() _res` parameter. It is not a
9
9
  * mistake and the value is never touched: its presence is how a handler tells
@@ -20,18 +20,8 @@ export declare class NestLensApiController {
20
20
  private readonly config;
21
21
  private readonly pruningService;
22
22
  private readonly collectorService;
23
- private lastPruneRun;
24
- private nextPruneRun;
25
- /**
26
- * Safely parse and bound pagination limit
27
- */
28
- private parseLimit;
29
- /**
30
- * Safely parse pagination offset
31
- */
32
- private parseOffset;
33
23
  constructor(storage: StorageInterface, config: NestLensConfig, pruningService: PruningService, collectorService: CollectorService);
34
- getEntries(type?: EntryType, requestId?: string, limit?: string, offset?: string, from?: string, to?: string, _res?: unknown): Promise<{
24
+ getEntries(query: EntriesQueryDto, _res?: unknown): Promise<{
35
25
  data: Entry[];
36
26
  meta: {
37
27
  total: number;
@@ -39,16 +29,36 @@ export declare class NestLensApiController {
39
29
  offset: number;
40
30
  };
41
31
  }>;
32
+ /**
33
+ * A page of one type, narrowed by a filter the storage applies.
34
+ *
35
+ * `logs` and `queries` used to read a page and then filter what came back,
36
+ * which chooses the matches out of the newest fifty rather than the newest
37
+ * fifty matches. On 5,005 logs whose five errors were the oldest,
38
+ * `?level=error` returned nothing at all and reported a total of 5,005 —
39
+ * a hundred pages to click through to reach the first match.
40
+ *
41
+ * `findWithCursor` applies filters before it chooses a page, in every
42
+ * backend, and counts what matches. Offset paging on top of it asks for
43
+ * `offset + limit` matches and drops the ones already shown, which is what
44
+ * an offset costs anywhere.
45
+ *
46
+ * Every list endpoint goes through here now. `entries`, `requests` and
47
+ * `exceptions` used `find`, which takes no filters at all, so they accepted
48
+ * `minDuration` and ignored it — the same silence, one path over. Two ways
49
+ * to answer the same question is how the two came to disagree.
50
+ */
51
+ private filteredPage;
42
52
  /**
43
53
  * Cursor-based pagination with comprehensive filtering
44
54
  * Uses CursorQueryDto to validate and transform all query parameters
45
55
  * NOTE: Must come BEFORE @Get('entries/:id') to avoid route conflicts
46
56
  */
47
57
  getEntriesWithCursor(query: CursorQueryDto, _res?: unknown): Promise<CursorPaginatedResponse<Entry>>;
48
- getLatestSequence(type?: EntryType, _res?: unknown): Promise<{
58
+ getLatestSequence(query: LatestSequenceQueryDto, _res?: unknown): Promise<{
49
59
  data: number | null;
50
60
  }>;
51
- checkNewEntries(afterSequence: string, type?: EntryType, _res?: unknown): Promise<{
61
+ checkNewEntries(query: CheckNewQueryDto, _res?: unknown): Promise<{
52
62
  data: {
53
63
  count: number;
54
64
  hasNew: boolean;
@@ -58,7 +68,7 @@ export declare class NestLensApiController {
58
68
  * Get entries grouped by family hash
59
69
  * NOTE: Must come BEFORE @Get('entries/:id') to avoid route conflict
60
70
  */
61
- getGroupedEntries(type?: EntryType, limit?: string, _res?: unknown): Promise<{
71
+ getGroupedEntries(query: EntriesQueryDto, _res?: unknown): Promise<{
62
72
  data: {
63
73
  familyHash: string;
64
74
  count: number;
@@ -69,7 +79,7 @@ export declare class NestLensApiController {
69
79
  * Get all entries with the same family hash
70
80
  * NOTE: Must come BEFORE @Get('entries/:id') to avoid route conflict
71
81
  */
72
- getEntriesByFamilyHash(hash: string, limit?: string, _res?: unknown): Promise<{
82
+ getEntriesByFamilyHash(hash: string, query: EntriesQueryDto, _res?: unknown): Promise<{
73
83
  data: Entry[];
74
84
  }>;
75
85
  getEntry(id: number, _res?: unknown): Promise<{
@@ -82,7 +92,7 @@ export declare class NestLensApiController {
82
92
  getStats(_res?: unknown): Promise<{
83
93
  data: import("../types").EntryStats;
84
94
  }>;
85
- getRequests(limit?: string, offset?: string, _res?: unknown): Promise<{
95
+ getRequests(query: EntriesQueryDto, _res?: unknown): Promise<{
86
96
  data: Entry[];
87
97
  meta: {
88
98
  total: number;
@@ -90,7 +100,7 @@ export declare class NestLensApiController {
90
100
  offset: number;
91
101
  };
92
102
  }>;
93
- getQueries(limit?: string, offset?: string, slow?: string, _res?: unknown): Promise<{
103
+ getQueries(query: QueriesQueryDto, _res?: unknown): Promise<{
94
104
  data: Entry[];
95
105
  meta: {
96
106
  total: number;
@@ -98,7 +108,7 @@ export declare class NestLensApiController {
98
108
  offset: number;
99
109
  };
100
110
  }>;
101
- getExceptions(limit?: string, offset?: string, _res?: unknown): Promise<{
111
+ getExceptions(query: EntriesQueryDto, _res?: unknown): Promise<{
102
112
  data: Entry[];
103
113
  meta: {
104
114
  total: number;
@@ -106,7 +116,7 @@ export declare class NestLensApiController {
106
116
  offset: number;
107
117
  };
108
118
  }>;
109
- getLogs(limit?: string, offset?: string, level?: string, _res?: unknown): Promise<{
119
+ getLogs(query: LogsQueryDto, _res?: unknown): Promise<{
110
120
  data: Entry[];
111
121
  meta: {
112
122
  total: number;
@@ -136,12 +146,20 @@ export declare class NestLensApiController {
136
146
  databaseSize: number | undefined;
137
147
  };
138
148
  }>;
149
+ /**
150
+ * Prunes now, by the same rules as the timer.
151
+ *
152
+ * This used to compute its own window from `config.pruning.maxAge`, which
153
+ * the service refuses to take at face value: `maxAge: 0` is ignored there
154
+ * and was honoured here, so pressing *Run pruning* with it set deleted every
155
+ * entry the application had recorded.
156
+ */
139
157
  runPruning(_res?: unknown): Promise<{
140
158
  success: boolean;
141
159
  data: {
142
160
  deleted: number;
143
- lastRun: string;
144
- nextRun: string;
161
+ lastRun: string | null;
162
+ nextRun: string | null;
145
163
  };
146
164
  }>;
147
165
  clearEntries(_res?: unknown): Promise<{
@@ -36,56 +36,54 @@ const exceptions_1 = require("../api/exceptions");
36
36
  * envelope shape lives in one place — the interceptor.
37
37
  */
38
38
  let NestLensApiController = class NestLensApiController {
39
- /**
40
- * Safely parse and bound pagination limit
41
- */
42
- parseLimit(limit) {
43
- if (!limit)
44
- return dto_1.DEFAULT_LIMIT;
45
- const parsed = parseInt(limit, 10);
46
- if (isNaN(parsed) || parsed < 1)
47
- return dto_1.DEFAULT_LIMIT;
48
- return Math.min(parsed, dto_1.MAX_LIMIT);
49
- }
50
- /**
51
- * Safely parse pagination offset
52
- */
53
- parseOffset(offset) {
54
- if (!offset)
55
- return 0;
56
- const parsed = parseInt(offset, 10);
57
- return isNaN(parsed) || parsed < 0 ? 0 : parsed;
58
- }
59
39
  constructor(storage, config, pruningService, collectorService) {
60
40
  this.storage = storage;
61
41
  this.config = config;
62
42
  this.pruningService = pruningService;
63
43
  this.collectorService = collectorService;
64
- this.lastPruneRun = null;
65
- this.nextPruneRun = null;
66
- // Calculate next prune run
67
- const intervalMinutes = this.config.pruning?.interval ?? 60;
68
- this.nextPruneRun = new Date(Date.now() + intervalMinutes * 60 * 1000);
69
44
  }
70
- async getEntries(type, requestId, limit, offset, from, to, _res) {
71
- const parsedLimit = this.parseLimit(limit);
72
- const parsedOffset = this.parseOffset(offset);
73
- const entries = await this.storage.find({
74
- type,
75
- requestId,
76
- limit: parsedLimit,
77
- offset: parsedOffset,
78
- from: from ? new Date(from) : undefined,
79
- to: to ? new Date(to) : undefined,
45
+ async getEntries(query, _res) {
46
+ return this.filteredPage(query.type, query);
47
+ }
48
+ /**
49
+ * A page of one type, narrowed by a filter the storage applies.
50
+ *
51
+ * `logs` and `queries` used to read a page and then filter what came back,
52
+ * which chooses the matches out of the newest fifty rather than the newest
53
+ * fifty matches. On 5,005 logs whose five errors were the oldest,
54
+ * `?level=error` returned nothing at all and reported a total of 5,005 —
55
+ * a hundred pages to click through to reach the first match.
56
+ *
57
+ * `findWithCursor` applies filters before it chooses a page, in every
58
+ * backend, and counts what matches. Offset paging on top of it asks for
59
+ * `offset + limit` matches and drops the ones already shown, which is what
60
+ * an offset costs anywhere.
61
+ *
62
+ * Every list endpoint goes through here now. `entries`, `requests` and
63
+ * `exceptions` used `find`, which takes no filters at all, so they accepted
64
+ * `minDuration` and ignored it — the same silence, one path over. Two ways
65
+ * to answer the same question is how the two came to disagree.
66
+ */
67
+ async filteredPage(type, query, filters) {
68
+ const limit = query.limit ?? dto_1.DEFAULT_LIMIT;
69
+ const offset = query.offset ?? 0;
70
+ const result = await this.storage.findWithCursor(type, {
71
+ limit: offset + limit,
72
+ filters: {
73
+ // The window and the duration bounds these endpoints accept. The
74
+ // window reached the storage on the `entries` path and not on this
75
+ // one, so `logs` and `queries` took a `from` and ignored it.
76
+ from: query.from?.toISOString(),
77
+ to: query.to?.toISOString(),
78
+ minDuration: query.minDuration,
79
+ maxDuration: query.maxDuration,
80
+ requestId: query.requestId,
81
+ ...filters,
82
+ },
80
83
  });
81
- const total = await this.storage.count(type);
82
84
  return {
83
- data: entries,
84
- meta: {
85
- total,
86
- limit: parsedLimit,
87
- offset: parsedOffset,
88
- },
85
+ data: result.data.slice(offset),
86
+ meta: { total: result.meta.total, limit, offset },
89
87
  };
90
88
  }
91
89
  /**
@@ -101,29 +99,32 @@ let NestLensApiController = class NestLensApiController {
101
99
  filters: query.toFilters(),
102
100
  });
103
101
  }
104
- async getLatestSequence(type, _res) {
105
- const sequence = await this.storage.getLatestSequence(type);
102
+ async getLatestSequence(query, _res) {
103
+ const sequence = await this.storage.getLatestSequence(query.type);
106
104
  return { data: sequence };
107
105
  }
108
- async checkNewEntries(afterSequence, type, _res) {
109
- const seq = parseInt(afterSequence, 10);
110
- const count = await this.storage.hasEntriesAfter(seq, type);
106
+ async checkNewEntries(query, _res) {
107
+ // `parseInt` of a missing or unreadable parameter is NaN, and NaN reached
108
+ // the storage: Redis was asked for `zcount (NaN +inf` and answered with an
109
+ // error. The live tail calls this on a timer, so it would have been a 500
110
+ // every few seconds rather than once.
111
+ const count = await this.storage.hasEntriesAfter(query.afterSequence, query.type);
111
112
  return { data: { count, hasNew: count > 0 } };
112
113
  }
113
114
  /**
114
115
  * Get entries grouped by family hash
115
116
  * NOTE: Must come BEFORE @Get('entries/:id') to avoid route conflict
116
117
  */
117
- async getGroupedEntries(type, limit, _res) {
118
- const groups = await this.storage.getGroupedByFamilyHash(type, this.parseLimit(limit));
118
+ async getGroupedEntries(query, _res) {
119
+ const groups = await this.storage.getGroupedByFamilyHash(query.type, query.limit ?? dto_1.DEFAULT_LIMIT);
119
120
  return { data: groups };
120
121
  }
121
122
  /**
122
123
  * Get all entries with the same family hash
123
124
  * NOTE: Must come BEFORE @Get('entries/:id') to avoid route conflict
124
125
  */
125
- async getEntriesByFamilyHash(hash, limit, _res) {
126
- const entries = await this.storage.findByFamilyHash(hash, this.parseLimit(limit));
126
+ async getEntriesByFamilyHash(hash, query, _res) {
127
+ const entries = await this.storage.findByFamilyHash(hash, query.limit ?? dto_1.DEFAULT_LIMIT);
127
128
  return { data: entries };
128
129
  }
129
130
  async getEntry(id, _res) {
@@ -148,53 +149,17 @@ let NestLensApiController = class NestLensApiController {
148
149
  const stats = await this.storage.getStats();
149
150
  return { data: stats };
150
151
  }
151
- async getRequests(limit, offset, _res) {
152
- return this.getEntries('request', undefined, limit, offset);
152
+ async getRequests(query, _res) {
153
+ return this.getEntries({ ...query, type: 'request' });
153
154
  }
154
- async getQueries(limit, offset, slow, _res) {
155
- const parsedLimit = this.parseLimit(limit);
156
- const parsedOffset = this.parseOffset(offset);
157
- const entries = await this.storage.find({
158
- type: 'query',
159
- limit: parsedLimit,
160
- offset: parsedOffset,
161
- });
162
- // Filter slow queries if requested
163
- const filtered = slow === 'true' ? entries.filter((e) => e.type === 'query' && e.payload.slow) : entries;
164
- const total = await this.storage.count('query');
165
- return {
166
- data: filtered,
167
- meta: {
168
- total,
169
- limit: parsedLimit,
170
- offset: parsedOffset,
171
- },
172
- };
155
+ async getQueries(query, _res) {
156
+ return this.filteredPage('query', query, query.slow === 'true' ? { slow: true } : undefined);
173
157
  }
174
- async getExceptions(limit, offset, _res) {
175
- return this.getEntries('exception', undefined, limit, offset);
158
+ async getExceptions(query, _res) {
159
+ return this.getEntries({ ...query, type: 'exception' });
176
160
  }
177
- async getLogs(limit, offset, level, _res) {
178
- const parsedLimit = this.parseLimit(limit);
179
- const parsedOffset = this.parseOffset(offset);
180
- const entries = await this.storage.find({
181
- type: 'log',
182
- limit: parsedLimit,
183
- offset: parsedOffset,
184
- });
185
- // Filter by level if requested
186
- const filtered = level
187
- ? entries.filter((e) => e.type === 'log' && e.payload.level === level)
188
- : entries;
189
- const total = await this.storage.count('log');
190
- return {
191
- data: filtered,
192
- meta: {
193
- total,
194
- limit: parsedLimit,
195
- offset: parsedOffset,
196
- },
197
- };
161
+ async getLogs(query, _res) {
162
+ return this.filteredPage('log', query, query.level ? { levels: [query.level] } : undefined);
198
163
  }
199
164
  /**
200
165
  * Storage stats endpoint
@@ -207,15 +172,18 @@ let NestLensApiController = class NestLensApiController {
207
172
  * Pruning endpoints
208
173
  */
209
174
  async getPruningStatus(_res) {
210
- const config = this.config.pruning;
211
175
  const storageStats = await this.storage.getStorageStats();
176
+ // Read from the service rather than from the configuration: a setting it
177
+ // refused or clamped is not the one in effect, and reporting the written
178
+ // value would describe pruning that is not happening.
179
+ const { lastRun, nextRun } = this.pruningService.schedule;
212
180
  return {
213
181
  data: {
214
- enabled: config?.enabled !== false,
215
- maxAge: config?.maxAge ?? 24,
216
- interval: config?.interval ?? 60,
217
- lastRun: this.lastPruneRun?.toISOString() ?? null,
218
- nextRun: this.nextPruneRun?.toISOString() ?? null,
182
+ enabled: this.config.pruning?.enabled !== false,
183
+ maxAge: this.pruningService.maxAgeHours,
184
+ interval: this.pruningService.intervalMinutes,
185
+ lastRun: lastRun?.toISOString() ?? null,
186
+ nextRun: nextRun?.toISOString() ?? null,
219
187
  totalEntries: storageStats.total,
220
188
  oldestEntry: storageStats.oldestEntry,
221
189
  newestEntry: storageStats.newestEntry,
@@ -223,19 +191,23 @@ let NestLensApiController = class NestLensApiController {
223
191
  },
224
192
  };
225
193
  }
194
+ /**
195
+ * Prunes now, by the same rules as the timer.
196
+ *
197
+ * This used to compute its own window from `config.pruning.maxAge`, which
198
+ * the service refuses to take at face value: `maxAge: 0` is ignored there
199
+ * and was honoured here, so pressing *Run pruning* with it set deleted every
200
+ * entry the application had recorded.
201
+ */
226
202
  async runPruning(_res) {
227
- const maxAgeHours = this.config.pruning?.maxAge ?? 24;
228
- const before = new Date(Date.now() - maxAgeHours * 60 * 60 * 1000);
229
- const deleted = await this.storage.prune(before);
230
- this.lastPruneRun = new Date();
231
- const intervalMinutes = this.config.pruning?.interval ?? 60;
232
- this.nextPruneRun = new Date(Date.now() + intervalMinutes * 60 * 1000);
203
+ const deleted = await this.pruningService.pruneNow();
204
+ const { lastRun, nextRun } = this.pruningService.schedule;
233
205
  return {
234
206
  success: true,
235
207
  data: {
236
208
  deleted,
237
- lastRun: this.lastPruneRun.toISOString(),
238
- nextRun: this.nextPruneRun.toISOString(),
209
+ lastRun: lastRun?.toISOString() ?? null,
210
+ nextRun: nextRun?.toISOString() ?? null,
239
211
  },
240
212
  };
241
213
  }
@@ -288,15 +260,10 @@ let NestLensApiController = class NestLensApiController {
288
260
  exports.NestLensApiController = NestLensApiController;
289
261
  __decorate([
290
262
  (0, common_1.Get)('entries'),
291
- __param(0, (0, common_1.Query)('type')),
292
- __param(1, (0, common_1.Query)('requestId')),
293
- __param(2, (0, common_1.Query)('limit')),
294
- __param(3, (0, common_1.Query)('offset')),
295
- __param(4, (0, common_1.Query)('from')),
296
- __param(5, (0, common_1.Query)('to')),
297
- __param(6, (0, common_1.Res)()),
263
+ __param(0, (0, common_1.Query)()),
264
+ __param(1, (0, common_1.Res)()),
298
265
  __metadata("design:type", Function),
299
- __metadata("design:paramtypes", [String, String, String, String, String, String, Object]),
266
+ __metadata("design:paramtypes", [dto_1.EntriesQueryDto, Object]),
300
267
  __metadata("design:returntype", Promise)
301
268
  ], NestLensApiController.prototype, "getEntries", null);
302
269
  __decorate([
@@ -309,37 +276,35 @@ __decorate([
309
276
  ], NestLensApiController.prototype, "getEntriesWithCursor", null);
310
277
  __decorate([
311
278
  (0, common_1.Get)('entries/latest-sequence'),
312
- __param(0, (0, common_1.Query)('type')),
279
+ __param(0, (0, common_1.Query)()),
313
280
  __param(1, (0, common_1.Res)()),
314
281
  __metadata("design:type", Function),
315
- __metadata("design:paramtypes", [String, Object]),
282
+ __metadata("design:paramtypes", [dto_1.LatestSequenceQueryDto, Object]),
316
283
  __metadata("design:returntype", Promise)
317
284
  ], NestLensApiController.prototype, "getLatestSequence", null);
318
285
  __decorate([
319
286
  (0, common_1.Get)('entries/check-new'),
320
- __param(0, (0, common_1.Query)('afterSequence')),
321
- __param(1, (0, common_1.Query)('type')),
322
- __param(2, (0, common_1.Res)()),
287
+ __param(0, (0, common_1.Query)()),
288
+ __param(1, (0, common_1.Res)()),
323
289
  __metadata("design:type", Function),
324
- __metadata("design:paramtypes", [String, String, Object]),
290
+ __metadata("design:paramtypes", [dto_1.CheckNewQueryDto, Object]),
325
291
  __metadata("design:returntype", Promise)
326
292
  ], NestLensApiController.prototype, "checkNewEntries", null);
327
293
  __decorate([
328
294
  (0, common_1.Get)('entries/grouped'),
329
- __param(0, (0, common_1.Query)('type')),
330
- __param(1, (0, common_1.Query)('limit')),
331
- __param(2, (0, common_1.Res)()),
295
+ __param(0, (0, common_1.Query)()),
296
+ __param(1, (0, common_1.Res)()),
332
297
  __metadata("design:type", Function),
333
- __metadata("design:paramtypes", [String, String, Object]),
298
+ __metadata("design:paramtypes", [dto_1.EntriesQueryDto, Object]),
334
299
  __metadata("design:returntype", Promise)
335
300
  ], NestLensApiController.prototype, "getGroupedEntries", null);
336
301
  __decorate([
337
302
  (0, common_1.Get)('entries/family/:hash'),
338
303
  __param(0, (0, common_1.Param)('hash')),
339
- __param(1, (0, common_1.Query)('limit')),
304
+ __param(1, (0, common_1.Query)()),
340
305
  __param(2, (0, common_1.Res)()),
341
306
  __metadata("design:type", Function),
342
- __metadata("design:paramtypes", [String, String, Object]),
307
+ __metadata("design:paramtypes", [String, dto_1.EntriesQueryDto, Object]),
343
308
  __metadata("design:returntype", Promise)
344
309
  ], NestLensApiController.prototype, "getEntriesByFamilyHash", null);
345
310
  __decorate([
@@ -359,40 +324,34 @@ __decorate([
359
324
  ], NestLensApiController.prototype, "getStats", null);
360
325
  __decorate([
361
326
  (0, common_1.Get)('requests'),
362
- __param(0, (0, common_1.Query)('limit')),
363
- __param(1, (0, common_1.Query)('offset')),
364
- __param(2, (0, common_1.Res)()),
327
+ __param(0, (0, common_1.Query)()),
328
+ __param(1, (0, common_1.Res)()),
365
329
  __metadata("design:type", Function),
366
- __metadata("design:paramtypes", [String, String, Object]),
330
+ __metadata("design:paramtypes", [dto_1.EntriesQueryDto, Object]),
367
331
  __metadata("design:returntype", Promise)
368
332
  ], NestLensApiController.prototype, "getRequests", null);
369
333
  __decorate([
370
334
  (0, common_1.Get)('queries'),
371
- __param(0, (0, common_1.Query)('limit')),
372
- __param(1, (0, common_1.Query)('offset')),
373
- __param(2, (0, common_1.Query)('slow')),
374
- __param(3, (0, common_1.Res)()),
335
+ __param(0, (0, common_1.Query)()),
336
+ __param(1, (0, common_1.Res)()),
375
337
  __metadata("design:type", Function),
376
- __metadata("design:paramtypes", [String, String, String, Object]),
338
+ __metadata("design:paramtypes", [dto_1.QueriesQueryDto, Object]),
377
339
  __metadata("design:returntype", Promise)
378
340
  ], NestLensApiController.prototype, "getQueries", null);
379
341
  __decorate([
380
342
  (0, common_1.Get)('exceptions'),
381
- __param(0, (0, common_1.Query)('limit')),
382
- __param(1, (0, common_1.Query)('offset')),
383
- __param(2, (0, common_1.Res)()),
343
+ __param(0, (0, common_1.Query)()),
344
+ __param(1, (0, common_1.Res)()),
384
345
  __metadata("design:type", Function),
385
- __metadata("design:paramtypes", [String, String, Object]),
346
+ __metadata("design:paramtypes", [dto_1.EntriesQueryDto, Object]),
386
347
  __metadata("design:returntype", Promise)
387
348
  ], NestLensApiController.prototype, "getExceptions", null);
388
349
  __decorate([
389
350
  (0, common_1.Get)('logs'),
390
- __param(0, (0, common_1.Query)('limit')),
391
- __param(1, (0, common_1.Query)('offset')),
392
- __param(2, (0, common_1.Query)('level')),
393
- __param(3, (0, common_1.Res)()),
351
+ __param(0, (0, common_1.Query)()),
352
+ __param(1, (0, common_1.Res)()),
394
353
  __metadata("design:type", Function),
395
- __metadata("design:paramtypes", [String, String, String, Object]),
354
+ __metadata("design:paramtypes", [dto_1.LogsQueryDto, Object]),
396
355
  __metadata("design:returntype", Promise)
397
356
  ], NestLensApiController.prototype, "getLogs", null);
398
357
  __decorate([
@@ -1,4 +1,5 @@
1
- import { CanActivate, ExecutionContext } from '@nestjs/common';
1
+ import { CanActivate, ExecutionContext, OnModuleDestroy } from '@nestjs/common';
2
+ import { HttpAdapterHost } from '@nestjs/core';
2
3
  import type { Request } from 'express';
3
4
  import { AuthUser, NestLensConfig } from '../nestlens.config';
4
5
  /**
@@ -7,8 +8,9 @@ import { AuthUser, NestLensConfig } from '../nestlens.config';
7
8
  export interface NestLensRequest extends Request {
8
9
  nestlensUser?: AuthUser;
9
10
  }
10
- export declare class NestLensGuard implements CanActivate {
11
+ export declare class NestLensGuard implements CanActivate, OnModuleDestroy {
11
12
  private readonly config;
13
+ private readonly httpAdapterHost?;
12
14
  private readonly logger;
13
15
  /**
14
16
  * In-memory rate limit store
@@ -19,8 +21,26 @@ export declare class NestLensGuard implements CanActivate {
19
21
  * Cleanup interval for expired entries (every 5 minutes)
20
22
  */
21
23
  private readonly cleanupInterval;
22
- constructor(config: NestLensConfig);
24
+ constructor(config: NestLensConfig, httpAdapterHost?: HttpAdapterHost | undefined);
25
+ /**
26
+ * Stops the cleanup timer with the application.
27
+ *
28
+ * `unref()` above keeps the timer from holding the process open, which is a
29
+ * different thing from stopping it: without this, a closed application leaves
30
+ * a timer still firing against a store nobody reads, and a test suite that
31
+ * creates guards leaves one behind per application it builds.
32
+ */
33
+ onModuleDestroy(): void;
23
34
  canActivate(context: ExecutionContext): Promise<boolean>;
35
+ /**
36
+ * Writes `Retry-After`, on whichever HTTP platform is underneath.
37
+ *
38
+ * Express and Fastify disagree about the method name; the adapter does not.
39
+ * Absent — in a unit test that builds the guard on its own — the header is
40
+ * simply not written, which is what happens anyway when there is no response
41
+ * to write it to.
42
+ */
43
+ private setRetryAfter;
24
44
  /**
25
45
  * Merge legacy config options with new authorization config
26
46
  */
@@ -34,7 +54,21 @@ export declare class NestLensGuard implements CanActivate {
34
54
  */
35
55
  private getCurrentEnvironment;
36
56
  /**
37
- * Evaluate canAccess function
57
+ * Runs the caller's access function and reads its answer as a decision.
58
+ *
59
+ * Only `true` and an object grant. Everything else denies, including the
60
+ * values a function returns when it did not decide anything: `undefined` from
61
+ * a branch with no `return`, `null` from a lookup that found nobody, `0` from
62
+ * a count. Each of those used to grant access, because the check was
63
+ * `result === false` and nothing else was refused — so a hook written as
64
+ *
65
+ * ```text
66
+ * canAccess: (req) => { if (!req.user) return false; }
67
+ * ```
68
+ *
69
+ * let everyone in through the branch its author forgot to write. An
70
+ * authorization hook is the one place where an unrecognised answer has to
71
+ * mean no.
38
72
  */
39
73
  private evaluateCanAccess;
40
74
  /**
@@ -44,6 +78,7 @@ export declare class NestLensGuard implements CanActivate {
44
78
  /**
45
79
  * Get client IP from request
46
80
  */
81
+ /** The client's address, by the same rule the request watcher records. */
47
82
  private getClientIp;
48
83
  /**
49
84
  * Check if IP matches allowed patterns
@@ -72,5 +107,12 @@ export declare class NestLensGuard implements CanActivate {
72
107
  /**
73
108
  * Cleanup expired rate limit entries to prevent memory leaks
74
109
  */
110
+ /**
111
+ * Keeps the store under its ceiling before adding to it.
112
+ *
113
+ * Only walked once the map is large: sweeping on every request would cost
114
+ * more than the entries do. See `MAX_RATE_LIMIT_KEYS`.
115
+ */
116
+ private makeRoom;
75
117
  private cleanupExpiredEntries;
76
118
  }